From 24a4dfdf83034c1f280841015e407f6d8bb94912 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Wed, 8 Aug 2007 05:05:30 +0000 Subject: [PATCH] [2.1.2?] Fix invisible DirectLex parsing error with empty elements that have attributes containing slashes git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1375 48356398-32a2-884e-a903-53898d9a118a --- NEWS | 4 ++++ library/HTMLPurifier/Lexer/DirectLex.php | 2 +- tests/HTMLPurifier/LexerTest.php | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index b88f59bc..4d173262 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,10 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier . Internal change ========================== +2.1.2, unknown release date +- Fix non-visible parsing error in DirectLex with empty tags that have + slashes inside attribute values. + 2.1.1, released 2007-08-04 - Fix show-stopper bug in %URI.MakeAbsolute functionality - Fix PHP4 syntax error in standalone version diff --git a/library/HTMLPurifier/Lexer/DirectLex.php b/library/HTMLPurifier/Lexer/DirectLex.php index 759c8f50..b3639916 100644 --- a/library/HTMLPurifier/Lexer/DirectLex.php +++ b/library/HTMLPurifier/Lexer/DirectLex.php @@ -237,7 +237,7 @@ class HTMLPurifier_Lexer_DirectLex extends HTMLPurifier_Lexer // trailing slash. Remember, we could have a tag like
, so // any later token processing scripts must convert improperly // classified EmptyTags from StartTags. - $is_self_closing= (strpos($segment,'/') === $strlen_segment-1); + $is_self_closing= (strrpos($segment,'/') === $strlen_segment-1); if ($is_self_closing) { $strlen_segment--; $segment = substr($segment, 0, $strlen_segment); diff --git a/tests/HTMLPurifier/LexerTest.php b/tests/HTMLPurifier/LexerTest.php index 9123bf6c..9388f0ab 100644 --- a/tests/HTMLPurifier/LexerTest.php +++ b/tests/HTMLPurifier/LexerTest.php @@ -351,6 +351,12 @@ class HTMLPurifier_LexerTest extends HTMLPurifier_Harness new HTMLPurifier_Token_Empty('a', array('href' => '><>')) ); + // empty tag with attributes + $input[25] = ''; + $expect[25] = array( + new HTMLPurifier_Token_Empty('param', array('name' => 'src', 'value' => 'http://example.com/video.wmv')) + ); + $default_config = HTMLPurifier_Config::createDefault(); $default_context = new HTMLPurifier_Context(); foreach($input as $i => $discard) { -- 2.11.4.GIT