From: Michael M Slusarz Date: Thu, 19 Aug 2010 17:07:14 +0000 (-0600) Subject: Bug #9187: Use same DOM loading technique that we use for XSS filter X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=0a4cf5ca50dc225931682195cd0fd36cd6ec9e62;p=horde.git Bug #9187: Use same DOM loading technique that we use for XSS filter --- diff --git a/framework/Text_Filter/lib/Horde/Text/Filter/Html2text.php b/framework/Text_Filter/lib/Horde/Text/Filter/Html2text.php index 71751feae..9212d9604 100644 --- a/framework/Text_Filter/lib/Horde/Text/Filter/Html2text.php +++ b/framework/Text_Filter/lib/Horde/Text/Filter/Html2text.php @@ -102,11 +102,14 @@ class Horde_Text_Filter_Html2text extends Horde_Text_Filter_Base public function postProcess($text) { if (extension_loaded('dom')) { - $text = Horde_String::convertCharset($text, $this->_params['charset'], 'UTF-8'); - $old_error = libxml_use_internal_errors(true); $doc = new DOMDocument(); - $doc->loadHTML('' . $text); + $doc->loadHTML($text); + if (!$doc->encoding) { + /* If libxml can't auto-detect encoding, convert to ISO-8859-1 + * manually. */ + $doc->loadHTML(Horde_String::convertCharset($text, $this->_params['charset'], 'ISO-8859-1')); + } if ($old_error) { libxml_use_internal_errors(false); }