mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-12-31 20:01:52 +00:00
Add tests for new entity decoding codepath.
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
This commit is contained in:
parent
98984546d4
commit
5bc7c72608
1
NEWS
1
NEWS
@ -11,6 +11,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
|
||||
|
||||
4.9.2, unknown release date
|
||||
- Fixes PHP 5.3 compatibility
|
||||
- Fix breakage when decoding decimal entities. Thanks @rybakit (#129)
|
||||
|
||||
4.9.1, released 2017-03-08
|
||||
! %URI.DefaultScheme can now be set to null, in which case
|
||||
|
@ -119,9 +119,9 @@ class HTMLPurifier_EntityParser
|
||||
$hex_part = @$matches[1];
|
||||
$dec_part = @$matches[2];
|
||||
$named_part = empty($matches[3]) ? @$matches[4] : $matches[3];
|
||||
if ($hex_part) {
|
||||
if ($hex_part !== NULL && $hex_part !== "") {
|
||||
return HTMLPurifier_Encoder::unichr(hexdec($hex_part));
|
||||
} elseif ($dec_part) {
|
||||
} elseif ($dec_part !== NULL && $dec_part !== "") {
|
||||
return HTMLPurifier_Encoder::unichr((int) $dec_part);
|
||||
} else {
|
||||
if (!$this->_entity_lookup) {
|
||||
|
@ -16,8 +16,12 @@ class HTMLPurifier_EntityParserTest extends HTMLPurifier_Harness
|
||||
$char_theta = $this->_entity_lookup->table['theta'];
|
||||
$this->assertIdentical($char_theta,
|
||||
$this->EntityParser->substituteNonSpecialEntities('θ') );
|
||||
$this->assertIdentical($char_theta,
|
||||
$this->EntityParser->substituteTextEntities('θ') );
|
||||
$this->assertIdentical('"',
|
||||
$this->EntityParser->substituteNonSpecialEntities('"') );
|
||||
$this->assertIdentical('"',
|
||||
$this->EntityParser->substituteTextEntities('"') );
|
||||
|
||||
// numeric tests, adapted from Feyd
|
||||
$args = array();
|
||||
@ -71,6 +75,11 @@ class HTMLPurifier_EntityParserTest extends HTMLPurifier_Harness
|
||||
$expect,
|
||||
'Identical expectation [Hex: '. dechex($arg[0]) .']'
|
||||
);
|
||||
$this->assertIdentical(
|
||||
$this->EntityParser->substituteTextEntities($string),
|
||||
$expect,
|
||||
'Identical expectation [Hex: '. dechex($arg[0]) .']'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -81,6 +90,10 @@ class HTMLPurifier_EntityParserTest extends HTMLPurifier_Harness
|
||||
"'",
|
||||
$this->EntityParser->substituteSpecialEntities(''')
|
||||
);
|
||||
$this->assertIdentical(
|
||||
"'",
|
||||
$this->EntityParser->substituteTextEntities(''')
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user