mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-01-03 13:21:51 +00:00
[1.3.1] Fixed bug in RemoveInvalidImg code that caused all images to be dropped
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@599 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
4f8f022eac
commit
cbb492c52c
2
NEWS
2
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
|
||||
|
@ -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 (
|
||||
|
@ -42,12 +42,15 @@ class HTMLPurifier_Strategy_RemoveForeignElementsTest
|
||||
' Warning!</span>'
|
||||
);
|
||||
|
||||
// test removal of img tag
|
||||
// test removal of invalid img tag
|
||||
$this->assertResult(
|
||||
'<img />',
|
||||
''
|
||||
);
|
||||
|
||||
// test preservation of valid img tag
|
||||
$this->assertResult('<img src="foobar.gif" />');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user