0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-01-03 05:11:52 +00:00

Make IE conditional comment matching ungreedy.

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
This commit is contained in:
Edward Z. Yang 2010-09-28 10:22:38 -04:00
parent 882ffed9ba
commit d848c99b74
3 changed files with 24 additions and 8 deletions

4
NEWS
View File

@ -9,6 +9,10 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
. Internal change . Internal change
========================== ==========================
4.2.1, unknown release date
- Make removal of conditional IE comments ungreedy; thanks Bernd
for reporting.
4.2.0, released 2010-09-15 4.2.0, released 2010-09-15
! Added %Core.RemoveProcessingInstructions, which lets you remove ! Added %Core.RemoveProcessingInstructions, which lets you remove
<? ... ?> statements. <? ... ?> statements.

View File

@ -235,7 +235,7 @@ class HTMLPurifier_Lexer
*/ */
protected static function removeIEConditional($string) { protected static function removeIEConditional($string) {
return preg_replace( return preg_replace(
'#<!--\[if [^>]+\]>.*<!\[endif\]-->#si', // probably should generalize for all strings '#<!--\[if [^>]+\]>.*?<!\[endif\]-->#si', // probably should generalize for all strings
'', '',
$string $string
); );

View File

@ -727,21 +727,33 @@ div {}
function test_tokenizeHTML_removeNewline() { function test_tokenizeHTML_removeNewline() {
$this->config->set('Core.NormalizeNewlines', true); $this->config->set('Core.NormalizeNewlines', true);
$input = "plain\rtext\r\n"; $this->assertTokenization(
$expect = array( "plain\rtext\r\n",
new HTMLPurifier_Token_Text("plain\ntext\n") array(
new HTMLPurifier_Token_Text("plain\ntext\n")
)
); );
} }
function test_tokenizeHTML_noRemoveNewline() { function test_tokenizeHTML_noRemoveNewline() {
$this->config->set('Core.NormalizeNewlines', false); $this->config->set('Core.NormalizeNewlines', false);
$input = "plain\rtext\r\n"; $this->assertTokenization(
$expect = array( "plain\rtext\r\n",
new HTMLPurifier_Token_Text("plain\rtext\r\n") array(
new HTMLPurifier_Token_Text("plain\rtext\r\n")
)
); );
$this->assertTokenization($input, $expect);
} }
function test_tokenizeHTML_conditionalCommentUngreedy() {
$this->assertTokenization(
'<!--[if gte mso 9]>a<![endif]-->b<!--[if gte mso 9]>c<![endif]-->',
array(
new HTMLPurifier_Token_Text("b")
)
);
}
/* /*