* (bug 534) Fix regression that broke slashes in extension tag parameters
authorBrion Vibber <brion@users.mediawiki.org>
Sat, 8 Apr 2006 04:40:09 +0000 (04:40 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sat, 8 Apr 2006 04:40:09 +0000 (04:40 +0000)
Patch by Jitse Niesen, http://bugzilla.wikimedia.org/attachment.cgi?id=1461

RELEASE-NOTES
includes/Parser.php
maintenance/parserTests.txt

index a217bc7..2c4a4b4 100644 (file)
@@ -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 ==
index 1775ead..6d031d6 100644 (file)
@@ -330,22 +330,29 @@ class Parser
                }
 
                if( $tag == STRIP_COMMENTS ) {
-                       $start = '/<!--()()/';
+                       $start = '/<!--()/';
                        $end   = '/-->/';
                } 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, <tag />
+                       if( $tag != STRIP_COMMENTS && substr( $attributes, -1 ) == '/' ) {
+                               $attributes = substr( $attributes, 0, -1);
+                               $empty = '/';
+                       } else {
+                               $empty = '';
+                       }
 
                        $marker = $rnd . sprintf('%08X', $n++);
                        $stripped .= $marker;
index da08388..ddd1232 100644 (file)
@@ -3500,6 +3500,19 @@ array(0) {
 
 !! end
 
+!! test
+Parser hook: empty input using terminated empty elements (space before)
+!! input
+<tag />
+!! result
+<pre>
+NULL
+array(0) {
+}
+</pre>
+
+!! 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
+<tag filename='/tmp/bla'></tag>
+!! result
+<pre>
+string(0) ""
+array(1) {
+  ["filename"]=>
+  string(8) "/tmp/bla"
+}
+</pre>
+
+!! end
+
 !! test
 Parser hook: empty input using terminated empty elements (bug 2374)
 !! input