Skip to content

Commit

Permalink
Remove PEARSax3 lexer.
Browse files Browse the repository at this point in the history
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
  • Loading branch information
ezyang committed Jan 3, 2012
1 parent e0354fe commit 94468f3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 194 deletions.
1 change: 1 addition & 0 deletions NEWS
Expand Up @@ -10,6 +10,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
==========================

4.4.0, unknown release date
# Removed PEARSax3 handler.
# URI.Munge now munges URIs inside the same host that go from https
to http. Reported by Neike Taika-Tessaro.
# Core.EscapeNonASCIICharacters now always transforms entities to
Expand Down
139 changes: 0 additions & 139 deletions library/HTMLPurifier/Lexer/PEARSax3.php

This file was deleted.

62 changes: 7 additions & 55 deletions tests/HTMLPurifier/LexerTest.php
Expand Up @@ -7,13 +7,6 @@ class HTMLPurifier_LexerTest extends HTMLPurifier_Harness

public function __construct() {
parent::__construct();
if ($GLOBALS['HTMLPurifierTest']['PEAR'] &&
// PEARSax3 is not maintained and throws loads of DEPRECATED
// errors in PHP 5.3
version_compare(PHP_VERSION, '5.3', '<')) {
require_once 'HTMLPurifier/Lexer/PEARSax3.php';
$this->_has_pear = true;
}
if ($GLOBALS['HTMLPurifierTest']['PH5P']) {
require_once 'HTMLPurifier/Lexer/PH5P.php';
}
Expand Down Expand Up @@ -158,7 +151,6 @@ function test_extractBody_useLastBody() {
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 (class_exists('DOMDocument')) {
$lexers['DOMLex'] = new HTMLPurifier_Lexer_DOMLex();
$lexers['PH5P'] = new HTMLPurifier_Lexer_PH5P();
Expand Down Expand Up @@ -299,7 +291,6 @@ function test_tokenizeHTML_unterminatedTag() {
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'=>'')) ),
'PH5P' => false, // total barfing, grabs scaffolding too
)
);
Expand All @@ -313,12 +304,11 @@ function test_tokenizeHTML_specialEntities() {
),
array(
// some parsers will separate entities out
'PEARSax3' => $split = array(
'PH5P' => array(
new HTMLPurifier_Token_Text('<'),
new HTMLPurifier_Token_Text('b'),
new HTMLPurifier_Token_Text('>'),
),
'PH5P' => $split,
)
);
}
Expand All @@ -329,10 +319,9 @@ function test_tokenizeHTML_earlyQuote() {
array( new HTMLPurifier_Token_Empty('a') ),
array(
// we barf on this input
'DirectLex' => $tokens = array(
'DirectLex' => array(
new HTMLPurifier_Token_Start('a', array('"' => ''))
),
'PEARSax3' => $tokens,
'PH5P' => false, // behavior varies; handle this personally
)
);
Expand Down Expand Up @@ -363,10 +352,7 @@ function test_tokenizeHTML_unescapedQuote() {
function test_tokenizeHTML_escapedQuote() {
$this->assertTokenization(
'&quot;',
array( new HTMLPurifier_Token_Text('"') ),
array(
'PEARSax3' => false, // PEAR barfs on this
)
array( new HTMLPurifier_Token_Text('"') )
);
}

Expand All @@ -375,8 +361,7 @@ function test_tokenizeHTML_cdata() {
'<![CDATA[You <b>can&#39;t</b> get me!]]>',
array( new HTMLPurifier_Token_Text('You <b>can&#39;t</b> get me!') ),
array(
// PEAR splits up all of the CDATA
'PEARSax3' => $split = array(
'PH5P' => array(
new HTMLPurifier_Token_Text('You '),
new HTMLPurifier_Token_Text('<'),
new HTMLPurifier_Token_Text('b'),
Expand All @@ -389,7 +374,6 @@ function test_tokenizeHTML_cdata() {
new HTMLPurifier_Token_Text('>'),
new HTMLPurifier_Token_Text(' get me!'),
),
'PH5P' => $split,
)
);
}
Expand All @@ -406,11 +390,10 @@ function test_tokenizeHTML_characterEntityInCDATA() {
'<![CDATA[&rarr;]]>',
array( new HTMLPurifier_Token_Text("&rarr;") ),
array(
'PEARSax3' => $split = array(
'PH5P' => array(
new HTMLPurifier_Token_Text('&'),
new HTMLPurifier_Token_Text('rarr;'),
),
'PH5P' => $split,
)
);
}
Expand Down Expand Up @@ -457,7 +440,6 @@ function test_tokenizeHTML_emoticonProtection() {
new HTMLPurifier_Token_Text('Whoa! <3 That\'s not good >.>'),
new HTMLPurifier_Token_End('b'),
),
'PEARSax3' => false, // totally mangled
'PH5P' => array( // interesting grouping
new HTMLPurifier_Token_Start('b'),
new HTMLPurifier_Token_Text('Whoa! '),
Expand All @@ -475,9 +457,6 @@ function test_tokenizeHTML_commentWithFunkyChars() {
array(
new HTMLPurifier_Token_Comment(' This >< comment '),
new HTMLPurifier_Token_Empty('br'),
),
array(
'PEARSax3' => false,
)
);
}
Expand All @@ -488,7 +467,6 @@ function test_tokenizeHTML_unterminatedComment() {
array( new HTMLPurifier_Token_Comment(' This >< comment') ),
array(
'DOMLex' => false,
'PEARSax3' => false,
'PH5P' => false,
)
);
Expand All @@ -505,7 +483,6 @@ function test_tokenizeHTML_scriptCDATAContents() {
new HTMLPurifier_Token_End('script'),
),
array(
'PEARSax3' => false,
// PH5P, for some reason, bubbles the script to <head>
'PH5P' => false,
)
Expand All @@ -515,10 +492,7 @@ function test_tokenizeHTML_scriptCDATAContents() {
function test_tokenizeHTML_entitiesInComment() {
$this->assertTokenization(
'<!-- This comment < &lt; & -->',
array( new HTMLPurifier_Token_Comment(' This comment < &lt; & ') ),
array(
'PEARSax3' => false
)
array( new HTMLPurifier_Token_Comment(' This comment < &lt; & ') )
);
}

Expand All @@ -531,8 +505,7 @@ function test_tokenizeHTML_attributeWithSpecialCharacters() {
new HTMLPurifier_Token_Start('a', array('href' => '')),
new HTMLPurifier_Token_Text('<'),
new HTMLPurifier_Token_Text('">'),
),
'PEARSax3' => false,
)
)
);
}
Expand Down Expand Up @@ -595,7 +568,6 @@ function test_tokenizeHTML_tagWithAtSignAndExtraGt() {
),
array(
'DirectLex' => $alt_expect,
'PEARSax3' => $alt_expect,
)
);
}
Expand All @@ -615,11 +587,6 @@ function test_tokenizeHTML_emoticonHeart() {
new HTMLPurifier_Token_Text('<3'),
new HTMLPurifier_Token_Empty('br'),
),
'PEARSax3' => array(
// bah too lazy to fix this
new HTMLPurifier_Token_Empty('br'),
new HTMLPurifier_Token_Empty('3<br'),
),
)
);
}
Expand All @@ -639,12 +606,6 @@ function test_tokenizeHTML_emoticonShiftyEyes() {
new HTMLPurifier_Token_Text('<<'),
new HTMLPurifier_Token_End('b'),
),
'PEARSax3' => array(
// also too lazy to fix
new HTMLPurifier_Token_Start('b'),
new HTMLPurifier_Token_Empty('<<'),
new HTMLPurifier_Token_Text('b>'),
),
)
);
}
Expand All @@ -666,13 +627,6 @@ function test_tokenizeHTML_eon1996() {
new HTMLPurifier_Token_Text('test'),
new HTMLPurifier_Token_End('b'),
),
'PEARSax3' => array(
// totally doing the wrong thing here
new HTMLPurifier_Token_Text(' '),
new HTMLPurifier_Token_Start('b'),
new HTMLPurifier_Token_Text('test'),
new HTMLPurifier_Token_End('b'),
),
)
);
}
Expand All @@ -694,7 +648,6 @@ function test_tokenizeHTML_bodyInCDATA() {
),
array(
'PH5P' => $alt_tokens,
'PEARSax3' => $alt_tokens,
)
);
}
Expand Down Expand Up @@ -777,7 +730,6 @@ function test_tokenizeHTML_imgTag() {
),
array(
'DirectLex' => $start,
'PEARSax3' => $start,
)
);
}
Expand Down

0 comments on commit 94468f3

Please sign in to comment.