mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-09 15:28:40 +00:00
Method purifyArray() updated (#143)
* Methof purifyArray() updated Now it works with multidimensional arrays * Add test case. Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
This commit is contained in:
parent
abba77a80b
commit
b91833877a
@ -240,12 +240,16 @@ class HTMLPurifier
|
||||
public function purifyArray($array_of_html, $config = null)
|
||||
{
|
||||
$context_array = array();
|
||||
foreach ($array_of_html as $key => $html) {
|
||||
$array_of_html[$key] = $this->purify($html, $config);
|
||||
foreach($array_of_html as $key=>$value){
|
||||
if (is_array($value)) {
|
||||
$array[$key] = $this->purifyArray($value, $config);
|
||||
} else {
|
||||
$array[$key] = $this->purify($value, $config);
|
||||
}
|
||||
$context_array[$key] = $this->context;
|
||||
}
|
||||
$this->context = $context_array;
|
||||
return $array_of_html;
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,6 +22,16 @@ class HTMLPurifierTest extends HTMLPurifier_Harness
|
||||
|
||||
}
|
||||
|
||||
public function test_purifyArray_nested()
|
||||
{
|
||||
$this->assertIdentical(
|
||||
$this->purifier->purifyArray(
|
||||
array('Good', '<b>Sketchy', 'foo' => array('bar' => '<script>bad</script>'))
|
||||
),
|
||||
array('Good', '<b>Sketchy</b>', 'foo' => array('bar' => ''))
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetInstance()
|
||||
{
|
||||
$purifier = HTMLPurifier::getInstance();
|
||||
|
Loading…
Reference in New Issue
Block a user