* (bug 1228) Fix double-escaping on & sequences in [enclosed] URLs
authorBrion Vibber <brion@users.mediawiki.org>
Sun, 30 Jan 2005 04:11:22 +0000 (04:11 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sun, 30 Jan 2005 04:11:22 +0000 (04:11 +0000)
includes/Parser.php
maintenance/parserTests.txt

index 1f1701e..3ed672b 100644 (file)
@@ -1015,6 +1015,11 @@ class Parser
                                }
                        }
 
+                       # Replace &amp; from obsolete syntax with &.
+                       # All HTML entities will be escaped by makeExternalLink()
+                       # or maybeMakeImageLink()
+                       $url = str_replace( '&amp;', '&', $url );
+
                        # Process the trail (i.e. everything after this link up until start of the next link),
                        # replacing any non-bracketed links
                        $trail = $this->replaceFreeExternalLinks( $trail );
index 79a6afd..47656ef 100644 (file)
@@ -480,6 +480,33 @@ Old &amp; use: http://x&y
 </p>
 !! end
 
+!! test
+External links: encoded ampersand
+!! input
+Old &amp; use: http://x&amp;y
+!! result
+<p>Old &amp; use: <a href="http://x&amp;y" class='external free' rel="nofollow">http://x&amp;y</a>
+</p>
+!! end
+
+!! test
+External links: [raw ampersand]
+!! input
+Old &amp; use: [http://x&y]
+!! result
+<p>Old &amp; use: <a href="http://x&amp;y" class='external autonumber' title="http://x&amp;y" rel="nofollow">[1]</a>
+</p>
+!! end
+
+!! test
+External links: [encoded ampersand]
+!! input
+Old &amp; use: [http://x&amp;y]
+!! result
+<p>Old &amp; use: <a href="http://x&amp;y" class='external autonumber' title="http://x&amp;y" rel="nofollow">[1]</a>
+</p>
+!! end
+
 !! test
 External links: www.jpeg.org (bug 554)
 !! input