From 5b34980e21ad55c5fe774ad5f3d1d130ee2cd096 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Thu, 14 Jun 2018 05:57:29 +0100 Subject: [PATCH] lib/php/mime.php --- lib/php/mime.php | 5 +++-- lib/postgres/html_tag.sql | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 lib/postgres/html_tag.sql diff --git a/lib/php/mime.php b/lib/php/mime.php index c038161d..82153308 100644 --- a/lib/php/mime.php +++ b/lib/php/mime.php @@ -718,7 +718,7 @@ class Mime { return true; } - public static function getContent($content) { + public static function fromContent($content) { if (!$content) return; static $finfo; @@ -858,7 +858,7 @@ class Mime { return $str; } - if ($mime === null) $mime = self::getContent($str); + if ($mime === null) $mime = self::fromContent($str); if ($mime == 'text/plain') { if ($v = self::html_video($str)) return $v; @@ -870,6 +870,7 @@ class Mime { #return $str .= '|'.$mime; if ($default === null) $default = $str; + if (strpos($mime,'text/')===0) $default = htmlentities($default); return $default; } diff --git a/lib/postgres/html_tag.sql b/lib/postgres/html_tag.sql new file mode 100644 index 00000000..eb8aaf66 --- /dev/null +++ b/lib/postgres/html_tag.sql @@ -0,0 +1,14 @@ +DROP TABLE IF EXISTS html_tag; +CREATE TABLE IF NOT EXISTS html_tag ( + tag varchar(1000) PRIMARY KEY, + link varchar(300), + description varchar(5000) +); +BEGIN TRANSACTION; +DELETE FROM html_tag; +COPY html_tag (tag,link,description) FROM PROGRAM '. /etc/profile && html2txt https://html.com/tags/ \ +| grep "^<" \ +| sed -E -e "s/ *HTML Tag *//" -e "s,^<([^>]+)>,\1\thttps://html.com/tags/iframe/\1/\t," \ +' WITH (format 'text', NULL ''); +COMMIT; + -- 2.47.3