yanwong / ganon

Automatically exported from code.google.com/p/ganon
0 stars 0 forks source link

toString_attributes, Invalid argument supplied for foreach() #49

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What will reproduce the problem?
include( 'ganon.php' );
$html = str_get_dom( '<html><body>foo bar<p>foobar</p><?php echo "foobar"; 
?></body></html>' );
echo $html;

What is the expected output? What do you see instead?
Expected:
<html><body>foo bar<p>foobar</p><?php echo "foobar"; ?></body></html>
Got:
PHP Warning:  Invalid argument supplied for foreach()
<html><body>foo bar<p>foobar</p><?php echo "foobar"; ?></body></html>

Which version are you using?
rev78

Please provide any additional information below.
Easy fix; in function toString_attributes( ) surround:
foreach($this->attributes as $a => $v) {
  $s .= ' '.$a.(((!$this->attribute_shorttag) || ($this->attributes[$a] !== $a)) ? '="'.htmlspecialchars($this->attributes[$a], ENT_QUOTES,$
}
with:
if(is_array($this->attributes)){
  ...
}

Original issue reported on code.google.com by stef...@balocco.name on 2 Sep 2013 at 10:52