mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-31 03:10:09 +02:00
Revamp entity decoding to be more like HTML5.
See %Core.LegacyEntityDecoder for more details. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
This commit is contained in:
@@ -46,11 +46,11 @@ class HTMLPurifier_LexerTest extends HTMLPurifier_Harness
|
||||
|
||||
// HTMLPurifier_Lexer->parseData() -----------------------------------------
|
||||
|
||||
public function assertParseData($input, $expect = true)
|
||||
public function assertParseData($input, $expect = true, $is_attr = false)
|
||||
{
|
||||
if ($expect === true) $expect = $input;
|
||||
$lexer = new HTMLPurifier_Lexer();
|
||||
$this->assertIdentical($expect, $lexer->parseData($input));
|
||||
$this->assertIdentical($expect, $lexer->parseData($input, $is_attr, $this->config));
|
||||
}
|
||||
|
||||
public function test_parseData_plainText()
|
||||
@@ -95,7 +95,58 @@ class HTMLPurifier_LexerTest extends HTMLPurifier_Harness
|
||||
|
||||
public function test_parseData_improperEntityFaultToleranceTest()
|
||||
{
|
||||
$this->assertParseData('-');
|
||||
$this->assertParseData('-', '-');
|
||||
}
|
||||
|
||||
public function test_parseData_noTrailingSemi()
|
||||
{
|
||||
$this->assertParseData('&A', '&A');
|
||||
}
|
||||
|
||||
public function test_parseData_noTrailingSemiAttr()
|
||||
{
|
||||
$this->assertParseData('&A', '&A', true);
|
||||
}
|
||||
|
||||
public function test_parseData_T119()
|
||||
{
|
||||
$this->assertParseData('&A', '&A', true);
|
||||
}
|
||||
|
||||
public function test_parseData_T119b()
|
||||
{
|
||||
$this->assertParseData('&trade=', true, true);
|
||||
}
|
||||
|
||||
public function test_parseData_legacy1()
|
||||
{
|
||||
$this->config->set('Core.LegacyEntityDecoder', true);
|
||||
$this->assertParseData('&a', true);
|
||||
$this->assertParseData('&=', "&=");
|
||||
$this->assertParseData('&a', true, true);
|
||||
$this->assertParseData('&=', "&=", true);
|
||||
$this->assertParseData('<a', true);
|
||||
$this->assertParseData('<=', "<=");
|
||||
$this->assertParseData('<a', true, true);
|
||||
$this->assertParseData('<=', "<=", true);
|
||||
}
|
||||
|
||||
public function test_parseData_nonlegacy1()
|
||||
{
|
||||
$this->assertParseData('&a', "&a");
|
||||
$this->assertParseData('&=', "&=");
|
||||
$this->assertParseData('&a', true, true);
|
||||
$this->assertParseData('&=', true, true);
|
||||
$this->assertParseData('<a', "<a");
|
||||
$this->assertParseData('<=', "<=");
|
||||
$this->assertParseData('<a', true, true);
|
||||
$this->assertParseData('<=', true, true);
|
||||
$this->assertParseData('<a;', "<a;");
|
||||
}
|
||||
|
||||
public function test_parseData_noTrailingSemiNever()
|
||||
{
|
||||
$this->assertParseData('&imath');
|
||||
}
|
||||
|
||||
// HTMLPurifier_Lexer->extractBody() ---------------------------------------
|
||||
|
Reference in New Issue
Block a user