1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-06 22:26:31 +02:00

fix: catastrophic backtracking in Core.AggressivelyFixLt (#440)

This commit is contained in:
Kieran
2025-06-06 04:49:52 +01:00
committed by GitHub
parent 77ebd08632
commit 418eeb7dc0
2 changed files with 121 additions and 10 deletions

View File

@@ -0,0 +1,40 @@
<?php
class HTMLPurifier_Lexer_DomLexTest extends HTMLPurifier_Harness
{
protected $domLex;
public function setUp()
{
$this->domLex = new HTMLPurifier_Lexer_DOMLex();
}
public function testCoreAggressivelyFixLtEmojis()
{
$context = new HTMLPurifier_Context();
$config = HTMLPurifier_Config::createDefault();
$output = $this->domLex->tokenizeHTML('<b><3</b>', $config, $context);
$this->assertIdentical($output, array(
new HTMLPurifier_Token_Start('b'),
new HTMLPurifier_Token_Text('<3'),
new HTMLPurifier_Token_End('b')
));
}
public function testCoreAggressivelyFixLtComments()
{
$context = new HTMLPurifier_Context();
$config = HTMLPurifier_Config::createDefault();
$output = $this->domLex->tokenizeHTML('<!-- Nested <!-- Not to be included --> comment -->', $config, $context);
$this->assertIdentical($output, array(
new HTMLPurifier_Token_Comment(' Nested <!-- Not to be included '),
new HTMLPurifier_Token_Text(' comment -->')
));
}
}
// vim: et sw=4 sts=4