* (bug 6102) For consistency with other markup, normalize all HTML-encoded
authorBrion Vibber <brion@users.mediawiki.org>
Sat, 27 May 2006 00:48:07 +0000 (00:48 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sat, 27 May 2006 00:48:07 +0000 (00:48 +0000)
  character entities in URLs, not just ampersands. This allows use of eg
  &#61; when making URLs for template parameters.

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

index 5d7eec8..51fe8f1 100644 (file)
@@ -352,6 +352,10 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   problems. If errors are transitory, this should reduce annoying messages
   making it into cached display.
 * (bug 6103) Wrap self-links in a CSS class ("selflink")
+* (bug 6102) For consistency with other markup, normalize all HTML-encoded
+  character entities in URLs, not just ampersands. This allows use of eg
+  &#61; when making URLs for template parameters.
+
 
 == Compatibility ==
 
index 7d4b1f8..7e703b7 100644 (file)
@@ -1196,9 +1196,9 @@ class Parser
 
                        $text = $wgContLang->markNoConversion($text);
 
-                       # Replace &amp; from obsolete syntax with &.
-                       # All HTML entities will be escaped by makeExternalLink()
-                       $url = str_replace( '&amp;', '&', $url );
+                       # Normalize any HTML entities in input. They will be
+                       # re-escaped by makeExternalLink().
+                       $url = Sanitizer::decodeCharReferences( $url );
 
                        # Process the trail (i.e. everything after this link up until start of the next link),
                        # replacing any non-bracketed links
@@ -1279,10 +1279,9 @@ class Parser
                                        $url = substr( $url, 0, -$numSepChars );
                                }
 
-                               # Replace &amp; from obsolete syntax with &.
-                               # All HTML entities will be escaped by makeExternalLink()
-                               # or maybeMakeExternalImage()
-                               $url = str_replace( '&amp;', '&', $url );
+                               # Normalize any HTML entities in input. They will be
+                               # re-escaped by makeExternalLink() or maybeMakeExternalImage()
+                               $url = Sanitizer::decodeCharReferences( $url );
 
                                # Is this an external image?
                                $text = $this->maybeMakeExternalImage( $url );
index 34dcf50..5653df2 100644 (file)
@@ -560,6 +560,15 @@ Old &amp; use: http://x&amp;y
 </p>
 !! end
 
+!! test
+External links: encoded equals (bug 6102)
+!! input
+http://example.com/?foo&#61;bar
+!! result
+<p><a href="http://example.com/?foo=bar" class='external free' title="http://example.com/?foo=bar" rel="nofollow">http://example.com/?foo=bar</a>
+</p>
+!! end
+
 !! test
 External links: [raw ampersand]
 !! input
@@ -578,6 +587,15 @@ Old &amp; use: [http://x&amp;y]
 </p>
 !! end
 
+!! test
+External links: [encoded equals] (bug 6102)
+!! input
+[http://example.com/?foo&#61;bar]
+!! result
+<p><a href="http://example.com/?foo=bar" class='external autonumber' title="http://example.com/?foo=bar" rel="nofollow">[1]</a>
+</p>
+!! end
+
 !! test
 External links: www.jpeg.org (bug 554)
 !! input