1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-07-30 19:00:10 +02:00

[3.1.0] Fix broken PH5P in latest versions of DOM with bandaid; punt to DirectLex.

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1698 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2008-04-26 19:47:22 +00:00
parent 144bd6f07a
commit 2f29c27a59
2 changed files with 34 additions and 10 deletions

View File

@@ -138,7 +138,7 @@ class HTMLPurifier_LexerTest extends HTMLPurifier_Harness
$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')) {
if (class_exists('DOMDocument')) {
$lexers['DOMLex'] = new HTMLPurifier_Lexer_DOMLex();
$lexers['PH5P'] = new HTMLPurifier_Lexer_PH5P();
}
@@ -310,13 +310,26 @@ class HTMLPurifier_LexerTest extends HTMLPurifier_Harness
new HTMLPurifier_Token_Start('a', array('"' => ''))
),
'PEARSax3' => $tokens,
'PH5P' => array(
new HTMLPurifier_Token_Empty('a', array('"' => ''))
),
'PH5P' => false, // behavior varies; handle this personally
)
);
}
function test_tokenizeHTML_earlyQuote_PH5P() {
if (!class_exists('DOMDocument')) return;
$lexer = new HTMLPurifier_Lexer_PH5P();
$result = $lexer->tokenizeHTML('<a "=>', $this->config, $this->context);
if ($this->context->get('PH5PError', true)) {
$this->assertIdentical(array(
new HTMLPurifier_Token_Start('a', array('"' => ''))
), $result);
} else {
$this->assertIdentical(array(
new HTMLPurifier_Token_Empty('a', array('"' => ''))
), $result);
}
}
function test_tokenizeHTML_unescapedQuote() {
$this->assertTokenization(
'"',