stevebauman/purify

Undefined variable: array

Closed this issue · 1 comments

After upgrading to laravel 7, i have this issue for some reason.

Undefined variable: array

In here:

 * @return string[] Array of purified HTML

 */

public function purifyArray($array_of_html, $config = null)

{

    $context_array = array();

    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;

}

What can be the problem?

I would run composer update and make sure you're on the latest HTMLPurifier, as I see the array being defined in the root repository here:

https://github.com/ezyang/htmlpurifier/blob/ced089434df320de6df9b610854b8fba8bfe1d1e/library/HTMLPurifier.php#L240-L254

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);
        } else {
            $array[$key] = $this->purify($value, $config);
        }
        $context_array[$key] = $this->context;
    }
    $this->context = $context_array;
    return $array;
}