From ced089434df320de6df9b610854b8fba8bfe1d1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A4ntz=20Miccoli?= Date: Sat, 22 Feb 2020 18:12:02 +0100 Subject: [PATCH] Make purifyArray work with empty array (#245) --- library/HTMLPurifier.php | 1 + tests/HTMLPurifierTest.php | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/library/HTMLPurifier.php b/library/HTMLPurifier.php index 58bbddb0..10e61c14 100644 --- a/library/HTMLPurifier.php +++ b/library/HTMLPurifier.php @@ -240,6 +240,7 @@ class HTMLPurifier public function purifyArray($array_of_html, $config = null) { $context_array = array(); + $array = array(); foreach($array_of_html as $key=>$value){ if (is_array($value)) { $array[$key] = $this->purifyArray($value, $config); diff --git a/tests/HTMLPurifierTest.php b/tests/HTMLPurifierTest.php index 2d28bc3c..a51038eb 100644 --- a/tests/HTMLPurifierTest.php +++ b/tests/HTMLPurifierTest.php @@ -32,6 +32,13 @@ class HTMLPurifierTest extends HTMLPurifier_Harness ); } + public function test_purifyArray_empty() { + $purifiedEmptyArray = $this->purifier->purifyArray(array()); + $this->assertTrue( + empty($purifiedEmptyArray) + ); + } + public function testGetInstance() { $purifier = HTMLPurifier::getInstance();