From 0e41e6e7a399e172c413762753847f25acdf8d2f Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 16 Apr 2015 15:23:21 -0700 Subject: [PATCH] New methods added to parser: addAllowedTag() and addAllowedAttribute() to use with the cleanHtml() method. --- e107_handlers/e_parse_class.php | 34 +++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php index 0cdaeb6da..1297a0802 100644 --- a/e107_handlers/e_parse_class.php +++ b/e107_handlers/e_parse_class.php @@ -2675,8 +2675,28 @@ class e_parser { $this->domObj = new DOMDocument(); } - - /** + + /** + * Add Allowed Tags. + * @param string + */ + public function addAllowedTag($tag) + { + $this->allowedTags[] = $tag; + } + + + /** + * @param $tag - html tag. + * @param $attArray - array of attributes. eg. array('style', 'id', 'class') etc. + */ + public function addAllowedAttribute($tag, $attArray) + { + $this->allowedAttributes[$tag] = (array) $attArray; + } + + + /** * Set Allowed Tags. * @param $array */ @@ -3428,7 +3448,7 @@ return; // print_a($p); } - + /** * Process and clean HTML from user input. @@ -3442,8 +3462,9 @@ return; if(empty($html)){ return ''; } $html = str_replace(' ', '@nbsp;', $html); // prevent replacement of   with spaces. - - if(preg_match("/'; } @@ -3470,7 +3491,8 @@ return; } - // Set it up for processing. + // Set it up for processing. + // libxml_use_internal_errors(true); // hides errors. $doc = $this->domObj; @$doc->loadHTML($html);