2006-07-23 00:11:03 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once 'HTMLPurifier/Lexer/DirectLex.php';
|
|
|
|
|
2007-08-01 14:06:59 +00:00
|
|
|
class HTMLPurifier_LexerTest extends HTMLPurifier_Harness
|
2006-07-23 00:11:03 +00:00
|
|
|
{
|
|
|
|
|
2006-08-10 12:41:39 +00:00
|
|
|
var $_has_pear = false;
|
2007-08-16 06:48:24 +00:00
|
|
|
|
|
|
|
function HTMLPurifier_LexerTest() {
|
|
|
|
parent::HTMLPurifier_Harness();
|
|
|
|
// E_STRICT = 2048, int used for PHP4 compat: this check disables
|
|
|
|
// PEAR if PHP 5 strict mode is on, since the class is not strict safe
|
|
|
|
if (
|
|
|
|
$GLOBALS['HTMLPurifierTest']['PEAR'] &&
|
|
|
|
((error_reporting() & 2048) != 2048) // ought to be a better way
|
2007-01-16 22:22:08 +00:00
|
|
|
) {
|
2006-08-10 12:41:39 +00:00
|
|
|
require_once 'HTMLPurifier/Lexer/PEARSax3.php';
|
2007-08-16 06:48:24 +00:00
|
|
|
$this->_has_pear = true;
|
2006-07-23 00:11:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-16 06:48:24 +00:00
|
|
|
// HTMLPurifier_Lexer::create() --------------------------------------------
|
|
|
|
|
2007-06-18 02:01:01 +00:00
|
|
|
function test_create() {
|
2007-08-16 06:48:24 +00:00
|
|
|
$this->config->set('Core', 'MaintainLineNumbers', true);
|
|
|
|
$lexer = HTMLPurifier_Lexer::create($this->config);
|
2007-06-18 02:01:01 +00:00
|
|
|
$this->assertIsA($lexer, 'HTMLPurifier_Lexer_DirectLex');
|
|
|
|
}
|
|
|
|
|
2007-08-16 06:48:24 +00:00
|
|
|
// HTMLPurifier_Lexer->parseData() -----------------------------------------
|
|
|
|
|
|
|
|
function assertParseData($input, $expect = true) {
|
|
|
|
if ($expect === true) $expect = $input;
|
|
|
|
$lexer = new HTMLPurifier_Lexer();
|
|
|
|
$this->assertIdentical($expect, $lexer->parseData($input));
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_parseData_plainText() {
|
|
|
|
$this->assertParseData('asdf');
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_parseData_ampersandEntity() {
|
|
|
|
$this->assertParseData('&', '&');
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_parseData_quotEntity() {
|
|
|
|
$this->assertParseData('"', '"');
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_parseData_aposNumericEntity() {
|
|
|
|
$this->assertParseData(''', "'");
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_parseData_aposCompactNumericEntity() {
|
|
|
|
$this->assertParseData(''', "'");
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_parseData_adjacentAmpersandEntities() {
|
|
|
|
$this->assertParseData('&&&', '&&&');
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_parseData_trailingUnescapedAmpersand() {
|
|
|
|
$this->assertParseData('&&', '&&');
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_parseData_internalUnescapedAmpersand() {
|
|
|
|
$this->assertParseData('Procter & Gamble');
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_parseData_improperEntityFaultToleranceTest() {
|
|
|
|
$this->assertParseData('-');
|
|
|
|
}
|
|
|
|
|
|
|
|
// HTMLPurifier_Lexer->extractBody() ---------------------------------------
|
|
|
|
|
2006-08-15 00:53:24 +00:00
|
|
|
function assertExtractBody($text, $extract = true) {
|
2007-08-16 06:48:24 +00:00
|
|
|
$lexer = new HTMLPurifier_Lexer();
|
|
|
|
$result = $lexer->extractBody($text);
|
2006-08-15 00:53:24 +00:00
|
|
|
if ($extract === true) $extract = $text;
|
|
|
|
$this->assertIdentical($extract, $result);
|
|
|
|
}
|
|
|
|
|
2007-08-16 06:48:24 +00:00
|
|
|
function test_extractBody_noBodyTags() {
|
|
|
|
$this->assertExtractBody('<b>Bold</b>');
|
2006-09-27 02:09:54 +00:00
|
|
|
}
|
|
|
|
|
2007-08-16 06:48:24 +00:00
|
|
|
function test_extractBody_lowercaseBodyTags() {
|
2006-08-15 00:53:24 +00:00
|
|
|
$this->assertExtractBody('<html><body><b>Bold</b></body></html>', '<b>Bold</b>');
|
2007-08-16 06:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_extractBody_uppercaseBodyTags() {
|
2006-08-15 01:14:39 +00:00
|
|
|
$this->assertExtractBody('<HTML><BODY><B>Bold</B></BODY></HTML>', '<B>Bold</B>');
|
2007-08-16 06:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_extractBody_realisticUseCase() {
|
2006-08-15 00:53:24 +00:00
|
|
|
$this->assertExtractBody(
|
2007-06-27 13:58:32 +00:00
|
|
|
'<?xml version="1.0"
|
2006-08-15 00:53:24 +00:00
|
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
|
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
|
|
<head>
|
|
|
|
<title>xyz</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<form method="post" action="whatever1">
|
|
|
|
<div>
|
|
|
|
<input type="text" name="username" />
|
|
|
|
<input type="text" name="password" />
|
|
|
|
<input type="submit" />
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</body>
|
|
|
|
</html>',
|
|
|
|
'
|
|
|
|
<form method="post" action="whatever1">
|
|
|
|
<div>
|
|
|
|
<input type="text" name="username" />
|
|
|
|
<input type="text" name="password" />
|
|
|
|
<input type="submit" />
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
');
|
2007-08-16 06:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_extractBody_bodyWithAttributes() {
|
2006-08-15 00:53:24 +00:00
|
|
|
$this->assertExtractBody('<html><body bgcolor="#F00"><b>Bold</b></body></html>', '<b>Bold</b>');
|
2007-08-16 06:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_extractBody_preserveUnclosedBody() {
|
2006-08-15 00:53:24 +00:00
|
|
|
$this->assertExtractBody('<body>asdf'); // not closed, don't accept
|
2007-08-16 06:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// HTMLPurifier_Lexer->tokenizeHTML() --------------------------------------
|
|
|
|
|
|
|
|
function assertTokenization($input, $expect, $alt_expect = array()) {
|
|
|
|
$lexers = array();
|
|
|
|
$lexers['DirectLex'] = new HTMLPurifier_Lexer_DirectLex();
|
|
|
|
if ($this->_has_pear) $lexers['PEARSax3'] = new HTMLPurifier_Lexer_PEARSax3();
|
|
|
|
if (version_compare(PHP_VERSION, "5", ">=") && class_exists('DOMDocument')) {
|
|
|
|
$lexers['DOMLex'] = new HTMLPurifier_Lexer_DOMLex();
|
|
|
|
}
|
|
|
|
foreach ($lexers as $name => $lexer) {
|
|
|
|
$result = $lexer->tokenizeHTML($input, $this->config, $this->context);
|
|
|
|
if (isset($alt_expect[$name])) {
|
|
|
|
if ($alt_expect[$name] === false) continue;
|
|
|
|
$this->assertIdentical($result, $alt_expect[$name]);
|
|
|
|
} else {
|
|
|
|
$this->assertIdentical($result, $expect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_tokenizeHTML_emptyInput() {
|
|
|
|
$this->assertTokenization('', array());
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_tokenizeHTML_plainText() {
|
|
|
|
$this->assertTokenization(
|
|
|
|
'This is regular text.',
|
|
|
|
array(
|
|
|
|
new HTMLPurifier_Token_Text('This is regular text.')
|
|
|
|
)
|
2007-04-04 02:22:27 +00:00
|
|
|
);
|
2007-08-16 06:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_tokenizeHTML_textAndTags() {
|
|
|
|
$this->assertTokenization(
|
|
|
|
'This is <b>bold</b> text',
|
|
|
|
array(
|
|
|
|
new HTMLPurifier_Token_Text('This is '),
|
|
|
|
new HTMLPurifier_Token_Start('b', array()),
|
|
|
|
new HTMLPurifier_Token_Text('bold'),
|
|
|
|
new HTMLPurifier_Token_End('b'),
|
|
|
|
new HTMLPurifier_Token_Text(' text'),
|
|
|
|
)
|
2007-06-27 16:40:18 +00:00
|
|
|
);
|
2007-08-16 06:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_tokenizeHTML_normalizeCase() {
|
|
|
|
$this->assertTokenization(
|
|
|
|
'<DIV>Totally rad dude. <b>asdf</b></div>',
|
|
|
|
array(
|
|
|
|
new HTMLPurifier_Token_Start('DIV', array()),
|
|
|
|
new HTMLPurifier_Token_Text('Totally rad dude. '),
|
|
|
|
new HTMLPurifier_Token_Start('b', array()),
|
|
|
|
new HTMLPurifier_Token_Text('asdf'),
|
|
|
|
new HTMLPurifier_Token_End('b'),
|
|
|
|
new HTMLPurifier_Token_End('div'),
|
|
|
|
)
|
2007-06-21 14:44:26 +00:00
|
|
|
);
|
2007-08-16 06:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_tokenizeHTML_notWellFormed() {
|
|
|
|
$this->assertTokenization(
|
|
|
|
'<asdf></asdf><d></d><poOloka><poolasdf><ds></asdf></ASDF>',
|
|
|
|
array(
|
|
|
|
new HTMLPurifier_Token_Start('asdf'),
|
|
|
|
new HTMLPurifier_Token_End('asdf'),
|
|
|
|
new HTMLPurifier_Token_Start('d'),
|
|
|
|
new HTMLPurifier_Token_End('d'),
|
|
|
|
new HTMLPurifier_Token_Start('poOloka'),
|
|
|
|
new HTMLPurifier_Token_Start('poolasdf'),
|
|
|
|
new HTMLPurifier_Token_Start('ds'),
|
|
|
|
new HTMLPurifier_Token_End('asdf'),
|
|
|
|
new HTMLPurifier_Token_End('ASDF'),
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
// DOMLex automatically closes invalid tags
|
|
|
|
'DOMLex' => array(
|
|
|
|
new HTMLPurifier_Token_Empty('asdf'),
|
|
|
|
new HTMLPurifier_Token_Empty('d'),
|
|
|
|
new HTMLPurifier_Token_Start('pooloka'),
|
|
|
|
new HTMLPurifier_Token_Start('poolasdf'),
|
|
|
|
new HTMLPurifier_Token_Empty('ds'),
|
|
|
|
new HTMLPurifier_Token_End('poolasdf'),
|
|
|
|
new HTMLPurifier_Token_End('pooloka'),
|
|
|
|
),
|
|
|
|
)
|
2007-06-21 14:44:26 +00:00
|
|
|
);
|
2007-08-16 06:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_tokenizeHTML_whitespaceInTag() {
|
|
|
|
$this->assertTokenization(
|
|
|
|
'<a'."\t".'href="foobar.php"'."\n".'title="foo!">Link to <b id="asdf">foobar</b></a>',
|
|
|
|
array(
|
|
|
|
new HTMLPurifier_Token_Start('a',array('href'=>'foobar.php','title'=>'foo!')),
|
|
|
|
new HTMLPurifier_Token_Text('Link to '),
|
|
|
|
new HTMLPurifier_Token_Start('b',array('id'=>'asdf')),
|
|
|
|
new HTMLPurifier_Token_Text('foobar'),
|
|
|
|
new HTMLPurifier_Token_End('b'),
|
|
|
|
new HTMLPurifier_Token_End('a'),
|
|
|
|
)
|
2007-06-26 16:08:42 +00:00
|
|
|
);
|
2007-08-16 06:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_tokenizeHTML_emptyTag() {
|
|
|
|
$this->assertTokenization(
|
|
|
|
'<br />',
|
|
|
|
array( new HTMLPurifier_Token_Empty('br') )
|
2007-07-05 21:29:07 +00:00
|
|
|
);
|
2007-08-16 06:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_tokenizeHTML_comment() {
|
|
|
|
$this->assertTokenization(
|
|
|
|
'<!-- Comment -->',
|
|
|
|
array( new HTMLPurifier_Token_Comment(' Comment ') )
|
2007-06-27 16:40:18 +00:00
|
|
|
);
|
2007-08-16 06:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_tokenizeHTML_malformedComment() {
|
|
|
|
$this->assertTokenization(
|
|
|
|
'<!-- not so well formed --->',
|
|
|
|
array( new HTMLPurifier_Token_Comment(' not so well formed -') ),
|
|
|
|
array(
|
|
|
|
'PEARSax3' => false, // behavior is undefined
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_tokenizeHTML_unterminatedTag() {
|
|
|
|
$this->assertTokenization(
|
|
|
|
'<a href=""',
|
|
|
|
array( new HTMLPurifier_Token_Text('<a href=""') ),
|
|
|
|
array(
|
|
|
|
// I like our behavior better, but it's non-standard
|
|
|
|
'DOMLex' => array( new HTMLPurifier_Token_Empty('a', array('href'=>'')) ),
|
|
|
|
'PEARSax3' => array( new HTMLPurifier_Token_Start('a', array('href'=>'')) ),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_tokenizeHTML_specialEntities() {
|
|
|
|
$this->assertTokenization(
|
|
|
|
'<b>',
|
|
|
|
array(
|
|
|
|
new HTMLPurifier_Token_Text('<b>')
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
// it is possible to configure PEARSax3 to clump nodes together,
|
|
|
|
// I just don't know how
|
|
|
|
'PEARSax3' => array(
|
|
|
|
new HTMLPurifier_Token_Text('<'),
|
|
|
|
new HTMLPurifier_Token_Text('b'),
|
|
|
|
new HTMLPurifier_Token_Text('>'),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_tokenizeHTML_earlyQuote() {
|
|
|
|
$this->assertTokenization(
|
|
|
|
'<a "=>',
|
|
|
|
array( new HTMLPurifier_Token_Empty('a') ),
|
|
|
|
array(
|
|
|
|
// we barf on this input
|
|
|
|
'DirectLex' => $tokens = array(
|
|
|
|
new HTMLPurifier_Token_Start('a', array('"' => ''))
|
|
|
|
),
|
|
|
|
'PEARSax3' => $tokens,
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_tokenizeHTML_unescapedQuote() {
|
|
|
|
$this->assertTokenization(
|
|
|
|
'"',
|
|
|
|
array( new HTMLPurifier_Token_Text('"') )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_tokenizeHTML_escapedQuote() {
|
|
|
|
$this->assertTokenization(
|
|
|
|
'"',
|
|
|
|
array( new HTMLPurifier_Token_Text('"') )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_tokenizeHTML_cdata() {
|
|
|
|
$this->assertTokenization(
|
|
|
|
'<![CDATA[You <b>can't</b> get me!]]>',
|
|
|
|
array( new HTMLPurifier_Token_Text('You <b>can't</b> get me!') ),
|
|
|
|
array(
|
|
|
|
// PEAR splits up all of the CDATA
|
|
|
|
'PEARSax3' => array(
|
|
|
|
new HTMLPurifier_Token_Text('You '),
|
|
|
|
new HTMLPurifier_Token_Text('<'),
|
|
|
|
new HTMLPurifier_Token_Text('b'),
|
|
|
|
new HTMLPurifier_Token_Text('>'),
|
|
|
|
new HTMLPurifier_Token_Text('can'),
|
|
|
|
new HTMLPurifier_Token_Text('&'),
|
|
|
|
new HTMLPurifier_Token_Text('#39;t'),
|
|
|
|
new HTMLPurifier_Token_Text('<'),
|
|
|
|
new HTMLPurifier_Token_Text('/b'),
|
|
|
|
new HTMLPurifier_Token_Text('>'),
|
|
|
|
new HTMLPurifier_Token_Text(' get me!'),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_tokenizeHTML_characterEntity() {
|
|
|
|
$this->assertTokenization(
|
|
|
|
'θ',
|
|
|
|
array( new HTMLPurifier_Token_Text("\xCE\xB8") )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_tokenizeHTML_characterEntityInCDATA() {
|
|
|
|
$this->assertTokenization(
|
|
|
|
'<![CDATA[→]]>',
|
|
|
|
array( new HTMLPurifier_Token_Text("→") ),
|
|
|
|
array(
|
|
|
|
'PEARSax3' => array(
|
|
|
|
new HTMLPurifier_Token_Text('&'),
|
|
|
|
new HTMLPurifier_Token_Text('rarr;'),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_tokenizeHTML_entityInAttribute() {
|
|
|
|
$this->assertTokenization(
|
|
|
|
'<a href="index.php?title=foo&id=bar">Link</a>',
|
|
|
|
array(
|
|
|
|
new HTMLPurifier_Token_Start('a',array('href' => 'index.php?title=foo&id=bar')),
|
|
|
|
new HTMLPurifier_Token_Text('Link'),
|
|
|
|
new HTMLPurifier_Token_End('a'),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_tokenizeHTML_preserveUTF8() {
|
|
|
|
$this->assertTokenization(
|
|
|
|
"\xCE\xB8",
|
|
|
|
array( new HTMLPurifier_Token_Text("\xCE\xB8") )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_tokenizeHTML_specialEntityInAttribute() {
|
|
|
|
$this->assertTokenization(
|
|
|
|
'<br test="x < 6" />',
|
|
|
|
array( new HTMLPurifier_Token_Empty('br', array('test' => 'x < 6')) )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_tokenizeHTML_emoticonProtection() {
|
|
|
|
$this->config->set('Core', 'AggressivelyFixLt', true);
|
|
|
|
$this->assertTokenization(
|
|
|
|
'<b>Whoa! <3 That\'s not good >.></b>',
|
|
|
|
array(
|
|
|
|
new HTMLPurifier_Token_Start('b'),
|
|
|
|
new HTMLPurifier_Token_Text('Whoa! '),
|
|
|
|
new HTMLPurifier_Token_Text('<3 That\'s not good >'),
|
|
|
|
new HTMLPurifier_Token_Text('.>'),
|
|
|
|
new HTMLPurifier_Token_End('b')
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
// text is absorbed together
|
|
|
|
'DOMLex' => array(
|
|
|
|
new HTMLPurifier_Token_Start('b'),
|
|
|
|
new HTMLPurifier_Token_Text('Whoa! <3 That\'s not good >.>'),
|
|
|
|
new HTMLPurifier_Token_End('b'),
|
|
|
|
),
|
|
|
|
'PEARSax3' => false, // totally mangled
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_tokenizeHTML_commentWithFunkyChars() {
|
|
|
|
$this->assertTokenization(
|
|
|
|
'<!-- This >< comment --><br />',
|
|
|
|
array(
|
|
|
|
new HTMLPurifier_Token_Comment(' This >< comment '),
|
|
|
|
new HTMLPurifier_Token_Empty('br'),
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'PEARSax3' => false,
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_tokenizeHTML_unterminatedComment() {
|
|
|
|
$this->assertTokenization(
|
|
|
|
'<!-- This >< comment',
|
|
|
|
array( new HTMLPurifier_Token_Comment(' This >< comment') ),
|
|
|
|
array(
|
|
|
|
'DOMLex' => false,
|
|
|
|
'PEARSax3' => false
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_tokenizeHTML_scriptCDATAContents() {
|
|
|
|
$this->config->set('HTML', 'Trusted', true);
|
|
|
|
$this->assertTokenization(
|
|
|
|
'<script>alert("<foo>");</script>',
|
|
|
|
array(
|
|
|
|
new HTMLPurifier_Token_Start('script'),
|
|
|
|
new HTMLPurifier_Token_Text('alert("<foo>");'),
|
|
|
|
new HTMLPurifier_Token_End('script'),
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'PEARSax3' => false,
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_tokenizeHTML_entitiesInComment() {
|
|
|
|
$this->config->set('Core', 'AggressivelyFixLt', true);
|
|
|
|
$this->assertTokenization(
|
|
|
|
'<!-- This comment < < & -->',
|
|
|
|
array( new HTMLPurifier_Token_Comment(' This comment < < & ') ),
|
|
|
|
array(
|
|
|
|
'PEARSax3' => false
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_tokenizeHTML_attributeWithSpecialCharacters() {
|
|
|
|
$this->assertTokenization(
|
|
|
|
'<a href="><>">',
|
|
|
|
array( new HTMLPurifier_Token_Empty('a', array('href' => '><>')) ),
|
|
|
|
array(
|
|
|
|
'DirectLex' => array(
|
|
|
|
new HTMLPurifier_Token_Start('a', array('href' => '')),
|
|
|
|
new HTMLPurifier_Token_Text('<">'),
|
|
|
|
),
|
|
|
|
'PEARSax3' => false,
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_tokenizeHTML_emptyTagWithSlashInAttribute() {
|
|
|
|
$this->assertTokenization(
|
|
|
|
'<param name="src" value="http://example.com/video.wmv" />',
|
|
|
|
array( new HTMLPurifier_Token_Empty('param', array('name' => 'src', 'value' => 'http://example.com/video.wmv')) )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
function test_tokenizeHTML_() {
|
|
|
|
$this->assertTokenization(
|
|
|
|
,
|
|
|
|
array(
|
|
|
|
|
|
|
|
)
|
2007-08-08 05:05:30 +00:00
|
|
|
);
|
2006-07-23 00:11:03 +00:00
|
|
|
}
|
2007-08-16 06:48:24 +00:00
|
|
|
*/
|
2006-07-23 00:11:03 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|