mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-01-20 12:31:53 +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)
|
(major feature release)
|
||||||
|
|
||||||
1.3.1, unknown release date
|
1.3.1, unknown release date
|
||||||
(security/bugfix/minor feature release)
|
|
||||||
! Added HTMLPurifier.func.php stub for a convenient function to call the library
|
! 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
|
1.3.0, released 2006-11-26
|
||||||
# Invalid images are now removed, rather than replaced with a dud
|
# 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
|
// hard-coded image special case, pre-emptively drop
|
||||||
// if not available. Probably not abstract-able
|
// if not available. Probably not abstract-able
|
||||||
if ( $token->name == 'img' ) {
|
if ( $token->name == 'img' ) {
|
||||||
if (!isset($token->attr['src'])) continue;
|
if (!isset($token->attributes['src'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!isset($definition->info['img']->attr['src'])) {
|
if (!isset($definition->info['img']->attr['src'])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$token->attr['src'] =
|
$token->attributes['src'] =
|
||||||
$definition->
|
$definition->
|
||||||
info['img']->
|
info['img']->
|
||||||
attr['src']->
|
attr['src']->
|
||||||
validate($token->attr['src']);
|
validate($token->attributes['src'],
|
||||||
if ($token->attr['src'] === false) continue;
|
$config, $context);
|
||||||
|
if ($token->attributes['src'] === false) continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif (
|
} elseif (
|
||||||
|
@ -42,12 +42,15 @@ class HTMLPurifier_Strategy_RemoveForeignElementsTest
|
|||||||
' Warning!</span>'
|
' Warning!</span>'
|
||||||
);
|
);
|
||||||
|
|
||||||
// test removal of img tag
|
// test removal of invalid img tag
|
||||||
$this->assertResult(
|
$this->assertResult(
|
||||||
'<img />',
|
'<img />',
|
||||||
''
|
''
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// test preservation of valid img tag
|
||||||
|
$this->assertResult('<img src="foobar.gif" />');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user