summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2018-12-21 17:50:16 +0300
committerAndrew Dolgov <[email protected]>2018-12-21 17:50:16 +0300
commita5517fe857535163d5989778108fd9d7eb891707 (patch)
tree4a0a3ddd4b77a9b2b109a8c54d7f744f012eebb3
parent782eda45db6861a09fc42bad396c3cb28505b28f (diff)
fetch_file_contents: decompress gzipped data
af_readability: remove utf8 preamble hack
-rwxr-xr-xclasses/rssutils.php2
-rwxr-xr-xinclude/functions.php17
-rwxr-xr-xplugins/af_readability/init.php3
3 files changed, 20 insertions, 2 deletions
diff --git a/classes/rssutils.php b/classes/rssutils.php
index ea57e6466..28bdda78b 100755
--- a/classes/rssutils.php
+++ b/classes/rssutils.php
@@ -1612,7 +1612,7 @@ class RSSUtils {
}
}
- private static function is_gzipped($feed_data) {
+ static function is_gzipped($feed_data) {
return mb_strpos($feed_data, "\x1f" . "\x8b" . "\x08", 0, "US-ASCII") === 0;
}
diff --git a/include/functions.php b/include/functions.php
index 1d83a41da..24c251bd3 100755
--- a/include/functions.php
+++ b/include/functions.php
@@ -437,6 +437,14 @@
curl_close($ch);
+ $is_gzipped = RSSUtils::is_gzipped($contents);
+
+ if ($is_gzipped) {
+ $tmp = @gzdecode($contents);
+
+ if ($tmp) $contents = $tmp;
+ }
+
return $contents;
} else {
@@ -522,6 +530,15 @@
return false;
}
+
+ $is_gzipped = RSSUtils::is_gzipped($data);
+
+ if ($is_gzipped) {
+ $tmp = @gzdecode($data);
+
+ if ($tmp) $data = $tmp;
+ }
+
return $data;
}
diff --git a/plugins/af_readability/init.php b/plugins/af_readability/init.php
index 339cc20d2..273f3d46b 100755
--- a/plugins/af_readability/init.php
+++ b/plugins/af_readability/init.php
@@ -148,6 +148,7 @@ class Af_Readability extends Plugin {
}
public function extract_content($url) {
+
global $fetch_effective_url;
$tmp = fetch_file_contents([
@@ -158,7 +159,7 @@ class Af_Readability extends Plugin {
if ($tmp && mb_strlen($tmp) < 1024 * 500) {
$tmpdoc = new DOMDocument("1.0", "UTF-8");
- if (!$tmpdoc->loadHTML('<?xml encoding="utf-8" ?>\n' . $tmp))
+ if (!$tmpdoc->loadHTML($tmp))
return false;
if (strtolower($tmpdoc->encoding) != 'utf-8') {