From aa446574598a3202562cc454aeb534d87eca0205 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sat, 27 May 2006 00:48:07 +0000 Subject: [PATCH] * (bug 6102) For consistency with other markup, normalize all HTML-encoded character entities in URLs, not just ampersands. This allows use of eg = when making URLs for template parameters. --- RELEASE-NOTES | 4 ++++ includes/Parser.php | 13 ++++++------- maintenance/parserTests.txt | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 5d7eec83a6..51fe8f19a2 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 + = when making URLs for template parameters. + == Compatibility == diff --git a/includes/Parser.php b/includes/Parser.php index 7d4b1f874d..7e703b7aec 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -1196,9 +1196,9 @@ class Parser $text = $wgContLang->markNoConversion($text); - # Replace & from obsolete syntax with &. - # All HTML entities will be escaped by makeExternalLink() - $url = str_replace( '&', '&', $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 & from obsolete syntax with &. - # All HTML entities will be escaped by makeExternalLink() - # or maybeMakeExternalImage() - $url = str_replace( '&', '&', $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 ); diff --git a/maintenance/parserTests.txt b/maintenance/parserTests.txt index 34dcf50ce4..5653df26fc 100644 --- a/maintenance/parserTests.txt +++ b/maintenance/parserTests.txt @@ -560,6 +560,15 @@ Old & use: http://x&y

!! end +!! test +External links: encoded equals (bug 6102) +!! input +http://example.com/?foo=bar +!! result +

http://example.com/?foo=bar +

+!! end + !! test External links: [raw ampersand] !! input @@ -578,6 +587,15 @@ Old & use: [http://x&y]

!! end +!! test +External links: [encoded equals] (bug 6102) +!! input +[http://example.com/?foo=bar] +!! result +

[1] +

+!! end + !! test External links: www.jpeg.org (bug 554) !! input -- 2.20.1