mirror of
https://github.com/e107inc/e107.git
synced 2025-08-08 07:36:32 +02:00
New methods added to parser: addAllowedTag() and addAllowedAttribute() to use with the cleanHtml() method.
This commit is contained in:
@@ -2676,6 +2676,26 @@ 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
|
||||
@@ -3443,7 +3463,8 @@ return;
|
||||
|
||||
$html = str_replace(' ', '@nbsp;', $html); // prevent replacement of with spaces.
|
||||
|
||||
if(preg_match("/<body/i",$html)!==true) // HTML Fragment
|
||||
|
||||
if(strpos($html, "<body")===false) // HTML Fragment
|
||||
{
|
||||
$html = '<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html><html><head><meta charset="utf-8"></head><body>'.$html.'</body></html>';
|
||||
}
|
||||
@@ -3471,6 +3492,7 @@ return;
|
||||
|
||||
|
||||
// Set it up for processing.
|
||||
// libxml_use_internal_errors(true); // hides errors.
|
||||
$doc = $this->domObj;
|
||||
|
||||
@$doc->loadHTML($html);
|
||||
|
Reference in New Issue
Block a user