From 783f280577bec77394830a1ba055210e82e32896 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sat, 8 Apr 2006 04:40:09 +0000 Subject: [PATCH] * (bug 534) Fix regression that broke slashes in extension tag parameters Patch by Jitse Niesen, http://bugzilla.wikimedia.org/attachment.cgi?id=1461 --- RELEASE-NOTES | 1 + includes/Parser.php | 17 ++++++++++++----- maintenance/parserTests.txt | 28 ++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index a217bc7ecd..2c4a4b4e0d 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -33,6 +33,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 5493) Id translation for special pages * Added skinname and style path parameters to CBT version of MonoBook * Include subversion revision number in Special:Version if available +* (bug 5344) Fix regression that broke slashes in extension tag parameters == Compatibility == diff --git a/includes/Parser.php b/includes/Parser.php index 1775eaddd7..6d031d6827 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -330,22 +330,29 @@ class Parser } if( $tag == STRIP_COMMENTS ) { - $start = '//'; } else { - $start = "/<$tag(\\s+[^\\/>]*|\\s*)(\\/?)>/i"; + $start = "/<$tag(\\s+[^>]*|\\s*\/?)>/i"; $end = "/<\\/$tag\\s*>/i"; } while ( '' != $text ) { $p = preg_split( $start, $text, 2, PREG_SPLIT_DELIM_CAPTURE ); $stripped .= $p[0]; - if( count( $p ) < 4 ) { + if( count( $p ) < 3 ) { break; } $attributes = $p[1]; - $empty = $p[2]; - $inside = $p[3]; + $inside = $p[2]; + + // If $attributes ends with '/', we have an empty element tag, + if( $tag != STRIP_COMMENTS && substr( $attributes, -1 ) == '/' ) { + $attributes = substr( $attributes, 0, -1); + $empty = '/'; + } else { + $empty = ''; + } $marker = $rnd . sprintf('%08X', $n++); $stripped .= $marker; diff --git a/maintenance/parserTests.txt b/maintenance/parserTests.txt index da08388e84..ddd1232441 100644 --- a/maintenance/parserTests.txt +++ b/maintenance/parserTests.txt @@ -3500,6 +3500,19 @@ array(0) { !! end +!! test +Parser hook: empty input using terminated empty elements (space before) +!! input + +!! result +
+NULL
+array(0) {
+}
+
+ +!! end + !! test Parser hook: basic input !! input @@ -3577,6 +3590,21 @@ array(4) { !! end +!! test +Parser hook: argument containing a forward slash (bug 5344) +!! input + +!! result +
+string(0) ""
+array(1) {
+  ["filename"]=>
+  string(8) "/tmp/bla"
+}
+
+ +!! end + !! test Parser hook: empty input using terminated empty elements (bug 2374) !! input -- 2.20.1