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
|
|
|
{
|
|
|
|
|
|
|
|
function invoke($input) {
|
|
|
|
$lexer = new HTMLPurifier_Lexer_DirectLex();
|
|
|
|
$lexer->tokenizeHTML($input, $this->config, $this->context);
|
|
|
|
}
|
|
|
|
|
|
|
|
function invokeAttr($input) {
|
|
|
|
$lexer = new HTMLPurifier_Lexer_DirectLex();
|
|
|
|
$lexer->parseAttributeString($input, $this->config, $this->context);
|
|
|
|
}
|
|
|
|
|
|
|
|
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('<!-- >');
|
|
|
|
}
|
|
|
|
|
|
|
|
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>');
|
|
|
|
}
|
|
|
|
|
|
|
|
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=""');
|
|
|
|
}
|
|
|
|
|
2007-06-26 19:33:37 +00:00
|
|
|
// these are sub-errors, will only be thrown in context of collector
|
|
|
|
|
2007-06-25 01:56:00 +00:00
|
|
|
function testMissingAttributeKey1() {
|
|
|
|
$this->expectErrorCollection(E_ERROR, 'Lexer: Missing attribute key');
|
|
|
|
$this->invokeAttr('=""');
|
|
|
|
}
|
|
|
|
|
|
|
|
function testMissingAttributeKey2() {
|
|
|
|
$this->expectErrorCollection(E_ERROR, 'Lexer: Missing attribute key');
|
|
|
|
$this->invokeAttr('foo="bar" =""');
|
|
|
|
}
|
|
|
|
|
|
|
|
function testMissingEndQuote() {
|
|
|
|
$this->expectErrorCollection(E_ERROR, 'Lexer: Missing end quote');
|
|
|
|
$this->invokeAttr('src="foo');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|