From: Michael M Slusarz Date: Thu, 19 Aug 2010 17:59:33 +0000 (-0600) Subject: More Html2text fixes X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=e1e160c088651055d80024107b4acd679a07265c;p=horde.git More Html2text fixes Use proper charset for html_entity_encode() and charset conversion. Fallback to strip_tags() if DOM extension is not available. --- diff --git a/framework/Text_Filter/lib/Horde/Text/Filter/Html2text.php b/framework/Text_Filter/lib/Horde/Text/Filter/Html2text.php index 9212d9604..1689d70ea 100644 --- a/framework/Text_Filter/lib/Horde/Text/Filter/Html2text.php +++ b/framework/Text_Filter/lib/Horde/Text/Filter/Html2text.php @@ -114,7 +114,9 @@ class Horde_Text_Filter_Html2text extends Horde_Text_Filter_Base libxml_use_internal_errors(false); } - $text = Horde_String::convertCharset($this->_node($doc, $doc), 'UTF-8', $this->_params['charset']); + $text = Horde_String::convertCharset($this->_node($doc, $doc), $doc->encoding, $this->_params['charset']); + } else { + $text = strip_tags(preg_replace("/\/i", "\n", $text)); } /* Bring down number of empty lines to 2 max, and remove trailing @@ -306,7 +308,7 @@ class Horde_Text_Filter_Html2text extends Horde_Text_Filter_Base if (!$child->nextSibling) { $tmp = rtrim($tmp); } - $out .= html_entity_decode($tmp, ENT_QUOTES, 'UTF-8'); + $out .= html_entity_decode($tmp, ENT_QUOTES, $this->_params['charset']); } } }