From 4d03c5c59f29f5fa59c45150f5c14937e0355892 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 6 Oct 2015 14:12:22 +0300 Subject: [PATCH] limit maximum article length allowed for readability --- plugins/af_readability/init.php | 2 +- plugins/af_redditimgur/init.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/af_readability/init.php b/plugins/af_readability/init.php index 8914ba43a..cfdcb69d3 100644 --- a/plugins/af_readability/init.php +++ b/plugins/af_readability/init.php @@ -119,7 +119,7 @@ class Af_Readability extends Plugin { $tmp = fetch_file_contents($article["link"]); - if ($tmp) { + if ($tmp && mb_strlen($tmp) < 65535 * 4) { $tmpdoc = new DOMDocument("1.0", "UTF-8"); if (!$tmpdoc->loadHTML($tmp)) diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index 9b3a999d3..ded98d8cc 100644 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -261,7 +261,10 @@ class Af_RedditImgur extends Plugin { $tmp = fetch_file_contents($content_link->getAttribute("href")); - if ($tmp) { + //_debug("tmplen: " . mb_strlen($tmp)); + + if ($tmp && mb_strlen($tmp) < 65535 * 4) { + $r = new Readability($tmp, $content_link->getAttribute("href")); if ($r->init()) {