]> git.wh0rd.org - tt-rss.git/blobdiff - plugins/af_readability/init.php
af_readability: check if sanitized content has anything before replacing
[tt-rss.git] / plugins / af_readability / init.php
index 48d9c2e37d50daac31eb2d9a3ba5355f4de94ed0..d1b165809ef9217076154406f3db011246b076a3 100755 (executable)
@@ -29,6 +29,10 @@ class Af_Readability extends Plugin {
        {
                $this->host = $host;
 
+               if (version_compare(PHP_VERSION, '5.6.0', '<')) {
+                       return;
+               }
+
                $host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
                $host->add_hook($host::HOOK_PREFS_TAB, $this);
                $host->add_hook($host::HOOK_PREFS_EDIT_FEED, $this);
@@ -42,6 +46,10 @@ class Af_Readability extends Plugin {
 
                print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Readability settings (af_readability)')."\">";
 
+               if (version_compare(PHP_VERSION, '5.6.0', '<')) {
+                       print_error("This plugin requires PHP version 5.6.");
+               }
+
                print_notice("Enable the plugin for specific feeds in the feed editor.");
 
                print "<form dojoType=\"dijit.form.Form\">";
@@ -201,7 +209,10 @@ class Af_Readability extends Plugin {
 
                $extracted_content = $this->extract_content($article["link"]);
 
-               if ($extracted_content) {
+               # let's see if there's anything of value in there
+               $content_test = trim(strip_tags(sanitize($extracted_content)));
+
+               if ($content_test) {
                        $article["content"] = $extracted_content;
                }