From 6d95e535248d91278816e88250cdeb278f6e38c2 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 21 Jun 2018 08:12:11 +0300 Subject: [PATCH] af_readability: check if sanitized content has anything before replacing original excerpt af_readability, af_redditimgur: check php version before using Readability --- plugins/af_readability/init.php | 13 ++++++- plugins/af_redditimgur/init.php | 68 +++------------------------------ 2 files changed, 18 insertions(+), 63 deletions(-) diff --git a/plugins/af_readability/init.php b/plugins/af_readability/init.php index 48d9c2e3..d1b16580 100755 --- a/plugins/af_readability/init.php +++ b/plugins/af_readability/init.php @@ -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 "
"; + 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 "
"; @@ -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; } diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index 735db1d6..4c9f6890 100755 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -32,6 +32,10 @@ class Af_RedditImgur extends Plugin { $enable_readability = $this->host->get($this, "enable_readability"); $enable_content_dupcheck = $this->host->get($this, "enable_content_dupcheck"); + if (version_compare(PHP_VERSION, '5.6.0', '<')) { + print_error("Readability requires PHP version 5.6."); + } + print ""; print "