mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-06 14:16:32 +02:00
Implement %HTML.AllowedComments and %HTML.AllowedCommentsRegexp
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
This commit is contained in:
@@ -100,6 +100,16 @@ alert(<b>bold</b>);
|
||||
$this->assertResult('<!-- bo --- asdf--as -->', '<!-- bo - asdf-as -->');
|
||||
}
|
||||
|
||||
function testPreserveCommentsWithLookup() {
|
||||
$this->config->set('HTML.AllowedComments', array('allowed'));
|
||||
$this->assertResult('<!-- allowed --><!-- not allowed -->', '<!-- allowed -->');
|
||||
}
|
||||
|
||||
function testPreserveCommentsWithRegexp() {
|
||||
$this->config->set('HTML.AllowedCommentsRegexp', '/^allowed[1-9]$/');
|
||||
$this->assertResult('<!-- allowed1 --><!-- not allowed -->', '<!-- allowed1 -->');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
||||
|
@@ -48,14 +48,14 @@ class HTMLPurifier_Strategy_RemoveForeignElements_ErrorsTest extends HTMLPurifie
|
||||
function testTrailingHyphenInCommentRemoved() {
|
||||
$this->config->set('HTML.Trusted', true);
|
||||
$this->expectErrorCollection(E_NOTICE, 'Strategy_RemoveForeignElements: Trailing hyphen in comment removed');
|
||||
$this->expectContext('CurrentToken', new HTMLPurifier_Token_Comment(' test --', 1));
|
||||
$this->expectContext('CurrentToken', new HTMLPurifier_Token_Comment(' test ', 1));
|
||||
$this->invoke('<!-- test ---->');
|
||||
}
|
||||
|
||||
function testDoubleHyphenInCommentRemoved() {
|
||||
$this->config->set('HTML.Trusted', true);
|
||||
$this->expectErrorCollection(E_NOTICE, 'Strategy_RemoveForeignElements: Hyphens in comment collapsed');
|
||||
$this->expectContext('CurrentToken', new HTMLPurifier_Token_Comment(' test --- test -- test ', 1));
|
||||
$this->expectContext('CurrentToken', new HTMLPurifier_Token_Comment(' test - test - test ', 1));
|
||||
$this->invoke('<!-- test --- test -- test -->');
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user