mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-01-03 21:21: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
|
4.9.2, unknown release date
|
||||||
- Fixes PHP 5.3 compatibility
|
- Fixes PHP 5.3 compatibility
|
||||||
|
- Fix breakage when decoding decimal entities. Thanks @rybakit (#129)
|
||||||
|
|
||||||
4.9.1, released 2017-03-08
|
4.9.1, released 2017-03-08
|
||||||
! %URI.DefaultScheme can now be set to null, in which case
|
! %URI.DefaultScheme can now be set to null, in which case
|
||||||
|
@ -119,9 +119,9 @@ class HTMLPurifier_EntityParser
|
|||||||
$hex_part = @$matches[1];
|
$hex_part = @$matches[1];
|
||||||
$dec_part = @$matches[2];
|
$dec_part = @$matches[2];
|
||||||
$named_part = empty($matches[3]) ? @$matches[4] : $matches[3];
|
$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));
|
return HTMLPurifier_Encoder::unichr(hexdec($hex_part));
|
||||||
} elseif ($dec_part) {
|
} elseif ($dec_part !== NULL && $dec_part !== "") {
|
||||||
return HTMLPurifier_Encoder::unichr((int) $dec_part);
|
return HTMLPurifier_Encoder::unichr((int) $dec_part);
|
||||||
} else {
|
} else {
|
||||||
if (!$this->_entity_lookup) {
|
if (!$this->_entity_lookup) {
|
||||||
|
@ -16,8 +16,12 @@ class HTMLPurifier_EntityParserTest extends HTMLPurifier_Harness
|
|||||||
$char_theta = $this->_entity_lookup->table['theta'];
|
$char_theta = $this->_entity_lookup->table['theta'];
|
||||||
$this->assertIdentical($char_theta,
|
$this->assertIdentical($char_theta,
|
||||||
$this->EntityParser->substituteNonSpecialEntities('θ') );
|
$this->EntityParser->substituteNonSpecialEntities('θ') );
|
||||||
|
$this->assertIdentical($char_theta,
|
||||||
|
$this->EntityParser->substituteTextEntities('θ') );
|
||||||
$this->assertIdentical('"',
|
$this->assertIdentical('"',
|
||||||
$this->EntityParser->substituteNonSpecialEntities('"') );
|
$this->EntityParser->substituteNonSpecialEntities('"') );
|
||||||
|
$this->assertIdentical('"',
|
||||||
|
$this->EntityParser->substituteTextEntities('"') );
|
||||||
|
|
||||||
// numeric tests, adapted from Feyd
|
// numeric tests, adapted from Feyd
|
||||||
$args = array();
|
$args = array();
|
||||||
@ -71,6 +75,11 @@ class HTMLPurifier_EntityParserTest extends HTMLPurifier_Harness
|
|||||||
$expect,
|
$expect,
|
||||||
'Identical expectation [Hex: '. dechex($arg[0]) .']'
|
'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->EntityParser->substituteSpecialEntities(''')
|
||||||
);
|
);
|
||||||
|
$this->assertIdentical(
|
||||||
|
"'",
|
||||||
|
$this->EntityParser->substituteTextEntities(''')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user