From a7762c5137fcf0a027bd57ad121875f0b024eaf8 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Thu, 15 May 2008 04:43:52 +0000 Subject: [PATCH] [2.1.4] [MFH] Fix bug in comment parsing with DirectLex from r1570 git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/branches/php4@1715 48356398-32a2-884e-a903-53898d9a118a --- NEWS | 1 + library/HTMLPurifier/Lexer/DirectLex.php | 8 ++------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 8d89d0da..990b9450 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier - Autoclose now operates iteratively, i.e.
now has both span tags closed. - Fix bug with trusted script handling in libxml versions later than 2.6.28. +- Fix bug in comment parsing with DirectLex 2.1.3, released 2007-11-05 ! tests/multitest.php allows you to test multiple versions by running diff --git a/library/HTMLPurifier/Lexer/DirectLex.php b/library/HTMLPurifier/Lexer/DirectLex.php index 86c0a211..e7f39361 100644 --- a/library/HTMLPurifier/Lexer/DirectLex.php +++ b/library/HTMLPurifier/Lexer/DirectLex.php @@ -168,7 +168,7 @@ class HTMLPurifier_Lexer_DirectLex extends HTMLPurifier_Lexer // Check if it's a comment if ( - substr($segment, 0, 3) === '!--' + strncmp('!--', $segment, 3) === 0 ) { // re-determine segment length, looking for --> $position_comment_end = strpos($html, '-->', $cursor); @@ -185,11 +185,7 @@ class HTMLPurifier_Lexer_DirectLex extends HTMLPurifier_Lexer $strlen_segment = $position_comment_end - $cursor; $segment = substr($html, $cursor, $strlen_segment); $token = new - HTMLPurifier_Token_Comment( - substr( - $segment, 3, $strlen_segment - 3 - ) - ); + HTMLPurifier_Token_Comment($segment, 3); if ($maintain_line_numbers) { $token->line = $current_line; $current_line += $this->substrCount($html, $nl, $cursor, $strlen_segment);