diff --git a/NEWS b/NEWS index 6c26835f..aef3b2e4 100644 --- a/NEWS +++ b/NEWS @@ -13,8 +13,8 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier (major feature release) 1.3.1, unknown release date -(security/bugfix/minor feature release) ! Added HTMLPurifier.func.php stub for a convenient function to call the library +. Fixed bug in RemoveInvalidImg code that caused all images to be dropped 1.3.0, released 2006-11-26 # Invalid images are now removed, rather than replaced with a dud diff --git a/library/HTMLPurifier/Strategy/RemoveForeignElements.php b/library/HTMLPurifier/Strategy/RemoveForeignElements.php index b06c864b..ec23b101 100644 --- a/library/HTMLPurifier/Strategy/RemoveForeignElements.php +++ b/library/HTMLPurifier/Strategy/RemoveForeignElements.php @@ -38,16 +38,19 @@ class HTMLPurifier_Strategy_RemoveForeignElements extends HTMLPurifier_Strategy // hard-coded image special case, pre-emptively drop // if not available. Probably not abstract-able if ( $token->name == 'img' ) { - if (!isset($token->attr['src'])) continue; + if (!isset($token->attributes['src'])) { + continue; + } if (!isset($definition->info['img']->attr['src'])) { continue; } - $token->attr['src'] = + $token->attributes['src'] = $definition-> info['img']-> attr['src']-> - validate($token->attr['src']); - if ($token->attr['src'] === false) continue; + validate($token->attributes['src'], + $config, $context); + if ($token->attributes['src'] === false) continue; } } elseif ( diff --git a/tests/HTMLPurifier/Strategy/RemoveForeignElementsTest.php b/tests/HTMLPurifier/Strategy/RemoveForeignElementsTest.php index 0318a85a..e2227705 100644 --- a/tests/HTMLPurifier/Strategy/RemoveForeignElementsTest.php +++ b/tests/HTMLPurifier/Strategy/RemoveForeignElementsTest.php @@ -42,12 +42,15 @@ class HTMLPurifier_Strategy_RemoveForeignElementsTest ' Warning!' ); - // test removal of img tag + // test removal of invalid img tag $this->assertResult( '', '' ); + // test preservation of valid img tag + $this->assertResult(''); + } }