From: Michael M Slusarz Date: Fri, 23 Jul 2010 16:08:17 +0000 (-0600) Subject: Allow Xss filter to return a DOMDocument object. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=15a4bac530af50296f53dfdd73c52c476882de10;p=horde.git Allow Xss filter to return a DOMDocument object. --- diff --git a/framework/Text_Filter/lib/Horde/Text/Filter/Xss.php b/framework/Text_Filter/lib/Horde/Text/Filter/Xss.php index 0e48997a1..52c715b45 100644 --- a/framework/Text_Filter/lib/Horde/Text/Filter/Xss.php +++ b/framework/Text_Filter/lib/Horde/Text/Filter/Xss.php @@ -15,6 +15,9 @@ * the document. * DEFAULT: false (returns the contents contained inside * the BODY tag) + * 'return_dom' - (boolean) If true, return a DOMDocument object instead of + * HTML text (overrides return_document). + * DEFAULT: false * 'strip_styles' - (boolean) Strip style tags? * DEFAULT: true * 'strip_style_attributes' - (boolean) Strip style attributes in all tags? @@ -43,6 +46,7 @@ class Horde_Text_Filter_Xss extends Horde_Text_Filter_Base 'charset' => 'UTF-8', 'noprefetch' => false, 'return_document' => false, + 'return_dom' => false, 'strip_styles' => true, 'strip_style_attributes' => true ); @@ -88,7 +92,8 @@ class Horde_Text_Filter_Xss extends Horde_Text_Filter_Base * * @param string $text The text after the filtering. * - * @return string The modified text. + * @return string|DOMDocument The modified text or a DOMDocument object + * if the 'return_dom' parameter is set. */ public function postProcess($text) { @@ -121,6 +126,10 @@ class Horde_Text_Filter_Xss extends Horde_Text_Filter_Base } } + if ($this->_params['return_dom']) { + return $doc; + } + $text = ''; if ($this->_params['return_document']) { $text = $doc->saveHTML();