From 671f4cee657f36881eeeea7e5d314034252e3ee7 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 21 Mar 2019 21:08:02 +0300 Subject: domdocument: remove old meta charset unicode hacks, replace with shorter xml preamble utf8 hack (on loadhtml where it makes sense) af_readability: better (?) charset hack for non-unicode pages --- plugins/af_readability/init.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'plugins/af_readability') diff --git a/plugins/af_readability/init.php b/plugins/af_readability/init.php index 117646c30..32c54a2c7 100755 --- a/plugins/af_readability/init.php +++ b/plugins/af_readability/init.php @@ -172,14 +172,10 @@ class Af_Readability extends Plugin { if (!$tmpdoc->loadHTML($tmp)) return false; + // this is the worst hack yet :( if (strtolower($tmpdoc->encoding) != 'utf-8') { - $tmpxpath = new DOMXPath($tmpdoc); - - foreach ($tmpxpath->query("//meta") as $elem) { - $elem->parentNode->removeChild($elem); - } - - $tmp = $tmpdoc->saveHTML(); + $tmp = preg_replace("//i", "", $tmp); + $tmp = mb_convert_encoding($tmp, 'utf-8', $tmpdoc->encoding); } try { @@ -210,7 +206,6 @@ class Af_Readability extends Plugin { } catch (Exception $e) { return false; } - } return false; -- cgit v1.2.3