mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-31 03:10:09 +02:00
Track column numbers in addition to line numbers.
Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com>
This commit is contained in:
@@ -9,43 +9,44 @@ class HTMLPurifier_Strategy_MakeWellFormed_ErrorsTest extends HTMLPurifier_Strat
|
||||
|
||||
function testUnnecessaryEndTagRemoved() {
|
||||
$this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Unnecessary end tag removed');
|
||||
$this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1));
|
||||
$this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 0));
|
||||
$this->invoke('</b>');
|
||||
}
|
||||
|
||||
function testUnnecessaryEndTagToText() {
|
||||
$this->config->set('Core', 'EscapeInvalidTags', true);
|
||||
$this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Unnecessary end tag to text');
|
||||
$this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1));
|
||||
$this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 0));
|
||||
$this->invoke('</b>');
|
||||
}
|
||||
|
||||
function testTagAutoClosed() {
|
||||
$this->expectErrorCollection(E_NOTICE, 'Strategy_MakeWellFormed: Tag auto closed', new HTMLPurifier_Token_Start('b', array(), 1));
|
||||
$this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('div', array(), 1));
|
||||
$this->expectErrorCollection(E_NOTICE, 'Strategy_MakeWellFormed: Tag auto closed', new HTMLPurifier_Token_Start('b', array(), 1, 0));
|
||||
$this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('div', array(), 1, 6));
|
||||
$this->invoke('<b>Foo<div>Bar</div>');
|
||||
}
|
||||
|
||||
function testStrayEndTagRemoved() {
|
||||
$this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Stray end tag removed');
|
||||
$this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1));
|
||||
$this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 3));
|
||||
$this->invoke('<i></b></i>');
|
||||
}
|
||||
|
||||
function testStrayEndTagToText() {
|
||||
$this->config->set('Core', 'EscapeInvalidTags', true);
|
||||
$this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Stray end tag to text');
|
||||
$this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1));
|
||||
$this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 3));
|
||||
$this->invoke('<i></b></i>');
|
||||
}
|
||||
|
||||
function testTagClosedByElementEnd() {
|
||||
$this->expectErrorCollection(E_NOTICE, 'Strategy_MakeWellFormed: Tag closed by element end', new HTMLPurifier_Token_Start('b', array(), 1));
|
||||
$this->expectErrorCollection(E_NOTICE, 'Strategy_MakeWellFormed: Tag closed by element end', new HTMLPurifier_Token_Start('b', array(), 1, 3));
|
||||
$this->expectContext('CurrentToken', new HTMLPurifier_Token_End('i', array(), 1, 12));
|
||||
$this->invoke('<i><b>Foobar</i>');
|
||||
}
|
||||
|
||||
function testTagClosedByDocumentEnd() {
|
||||
$this->expectErrorCollection(E_NOTICE, 'Strategy_MakeWellFormed: Tag closed by document end', new HTMLPurifier_Token_Start('b', array(), 1));
|
||||
$this->expectErrorCollection(E_NOTICE, 'Strategy_MakeWellFormed: Tag closed by document end', new HTMLPurifier_Token_Start('b', array(), 1, 0));
|
||||
$this->invoke('<b>Foobar');
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user