diff --git a/library/HTMLPurifier.php b/library/HTMLPurifier.php index bada5188..76abb544 100644 --- a/library/HTMLPurifier.php +++ b/library/HTMLPurifier.php @@ -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; } /** diff --git a/tests/HTMLPurifierTest.php b/tests/HTMLPurifierTest.php index 1fbcddf8..2d28bc3c 100644 --- a/tests/HTMLPurifierTest.php +++ b/tests/HTMLPurifierTest.php @@ -22,6 +22,16 @@ class HTMLPurifierTest extends HTMLPurifier_Harness } + public function test_purifyArray_nested() + { + $this->assertIdentical( + $this->purifier->purifyArray( + array('Good', 'Sketchy', 'foo' => array('bar' => '')) + ), + array('Good', 'Sketchy', 'foo' => array('bar' => '')) + ); + } + public function testGetInstance() { $purifier = HTMLPurifier::getInstance();