]> git.nbdom.net Git - nb.git/commitdiff
lib/php/mime.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 14 Jun 2018 04:57:29 +0000 (05:57 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 14 Jun 2018 04:57:29 +0000 (05:57 +0100)
lib/php/mime.php
lib/postgres/html_tag.sql [new file with mode: 0644]

index c038161d3c43ab37973239d59534bd713fc02508..82153308b21258b3eb99b167d89fa5eee1a634b7 100644 (file)
@@ -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 (file)
index 0000000..eb8aaf6
--- /dev/null
@@ -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;
+