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 8914ba43..cfdcb69d 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 9b3a999d..ded98d8c 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()) { -- 2.39.5