mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-30 19:00:10 +02:00
[1.7.0] Unit test for ElementDef created, ElementDef behavior modified to be more flexible
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1038 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@@ -99,16 +99,20 @@ class HTMLPurifier_ElementDef
|
||||
// merge in the includes
|
||||
// sorry, no way to override an include
|
||||
foreach ($v as $v2) {
|
||||
$def->attr[0][] = $v2;
|
||||
$this->attr[0][] = $v2;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if ($v === false) {
|
||||
if (isset($this->attr[$k])) unset($this->attr[$k]);
|
||||
continue;
|
||||
}
|
||||
$this->attr[$k] = $v;
|
||||
}
|
||||
foreach($def->attr_transform_pre as $k => $v) $this->attr_transform_pre[$k] = $v;
|
||||
foreach($def->attr_transform_post as $k => $v) $this->attr_transform_post[$k] = $v;
|
||||
foreach($def->auto_close as $k => $v) $this->auto_close[$k] = $v;
|
||||
foreach($def->excludes as $k => $v) $this->excludes[$k] = $v;
|
||||
$this->_mergeAssocArray($this->attr_transform_pre, $def->attr_transform_pre);
|
||||
$this->_mergeAssocArray($this->attr_transform_post, $def->attr_transform_post);
|
||||
$this->_mergeAssocArray($this->auto_close, $def->auto_close);
|
||||
$this->_mergeAssocArray($this->excludes, $def->excludes);
|
||||
|
||||
if(!is_null($def->child)) $this->child = $def->child;
|
||||
if(!empty($def->content_model)) $this->content_model .= ' | ' . $def->content_model;
|
||||
@@ -117,6 +121,21 @@ class HTMLPurifier_ElementDef
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges one array into another, removes values which equal false
|
||||
* @param $a1 Array by reference that is merged into
|
||||
* @param $a2 Array that merges into $a1
|
||||
*/
|
||||
function _mergeAssocArray(&$a1, $a2) {
|
||||
foreach ($a2 as $k => $v) {
|
||||
if ($v === false) {
|
||||
if (isset($a1[$k])) unset($a1[$k]);
|
||||
continue;
|
||||
}
|
||||
$a1[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
Reference in New Issue
Block a user