2007-06-25 01:56:00 +00:00
|
|
|
<?php
|
|
|
|
|
2007-06-26 02:49:21 +00:00
|
|
|
class HTMLPurifier_Lexer_DirectLex_ErrorsTest extends HTMLPurifier_ErrorsHarness
|
2007-06-25 01:56:00 +00:00
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-06-25 01:56:00 +00:00
|
|
|
function invoke($input) {
|
|
|
|
$lexer = new HTMLPurifier_Lexer_DirectLex();
|
|
|
|
$lexer->tokenizeHTML($input, $this->config, $this->context);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-06-25 01:56:00 +00:00
|
|
|
function invokeAttr($input) {
|
|
|
|
$lexer = new HTMLPurifier_Lexer_DirectLex();
|
|
|
|
$lexer->parseAttributeString($input, $this->config, $this->context);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2010-05-04 17:41:09 +00:00
|
|
|
function testExtractBody() {
|
|
|
|
$this->expectErrorCollection(E_WARNING, 'Lexer: Extracted body');
|
|
|
|
$this->invoke('<body>foo</body>');
|
|
|
|
}
|
|
|
|
|
2007-06-25 01:56:00 +00:00
|
|
|
function testUnclosedComment() {
|
|
|
|
$this->expectErrorCollection(E_WARNING, 'Lexer: Unclosed comment');
|
2007-06-26 19:33:37 +00:00
|
|
|
$this->expectContext('CurrentLine', 1);
|
2007-06-25 01:56:00 +00:00
|
|
|
$this->invoke('<!-- >');
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-06-25 01:56:00 +00:00
|
|
|
function testUnescapedLt() {
|
|
|
|
$this->expectErrorCollection(E_NOTICE, 'Lexer: Unescaped lt');
|
2007-06-26 19:33:37 +00:00
|
|
|
$this->expectContext('CurrentLine', 1);
|
2007-06-25 01:56:00 +00:00
|
|
|
$this->invoke('< foo>');
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-06-25 01:56:00 +00:00
|
|
|
function testMissingGt() {
|
|
|
|
$this->expectErrorCollection(E_WARNING, 'Lexer: Missing gt');
|
2007-06-26 19:33:37 +00:00
|
|
|
$this->expectContext('CurrentLine', 1);
|
2007-06-25 01:56:00 +00:00
|
|
|
$this->invoke('<a href=""');
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-06-26 19:33:37 +00:00
|
|
|
// these are sub-errors, will only be thrown in context of collector
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-06-25 01:56:00 +00:00
|
|
|
function testMissingAttributeKey1() {
|
|
|
|
$this->expectErrorCollection(E_ERROR, 'Lexer: Missing attribute key');
|
|
|
|
$this->invokeAttr('=""');
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-06-25 01:56:00 +00:00
|
|
|
function testMissingAttributeKey2() {
|
|
|
|
$this->expectErrorCollection(E_ERROR, 'Lexer: Missing attribute key');
|
|
|
|
$this->invokeAttr('foo="bar" =""');
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-06-25 01:56:00 +00:00
|
|
|
function testMissingEndQuote() {
|
|
|
|
$this->expectErrorCollection(E_ERROR, 'Lexer: Missing end quote');
|
|
|
|
$this->invokeAttr('src="foo');
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-06-25 01:56:00 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 09:24:59 +00:00
|
|
|
// vim: et sw=4 sts=4
|