From: Brian Wolff Date: Fri, 24 Dec 2010 09:53:08 +0000 (+0000) Subject: (Bug 26410) In an internal link, a plus sign is treated as a space if the link X-Git-Tag: 1.31.0-rc.0~33118 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=ff5394caed9fd799aa85ca8c77031bc9852492f1;p=lhc%2Fweb%2Fwiklou.git (Bug 26410) In an internal link, a plus sign is treated as a space if the link has a % sign in it, but interperted as a + if no % sign is present. This changes how the parser interperts links slightly. However: *I can't imagine anyone is relying on this behaviour *Things should be consistent. a + sign shouldn't magically change meaning if there is a % sign somewhere else in the link. *Pages are allowed to contain % signs in their title, and + signs, you should be able to link to such pages just by typing there name without resorting to %2B. *If you have a page named foo%+ having [[{{PAGENAME}}]] link to a different page seems inherently wrong. *The previous behaviour seemed accidental. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 0304627666..b2823b04fa 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -40,6 +40,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 18372) File types blacklisted by $wgFileBlacklist will no longer be shown as "Permitted file types" on the upload form * (bug 26379) importImages.php gives more descriptive error message on failure. +* (Bug 26410) + signs are no longer treated as spaces in internal links if + link has a % sign in it. === API changes in 1.18 === * (bug 26339) Throw warning when truncating an overlarge API result diff --git a/includes/Linker.php b/includes/Linker.php index 70d2b8a4c0..2d067402a9 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1102,7 +1102,7 @@ class Linker { # fix up urlencoded title texts (copied from Parser::replaceInternalLinks) if ( strpos( $match[1], '%' ) !== false ) { - $match[1] = str_replace( array( '<', '>' ), array( '<', '>' ), urldecode( $match[1] ) ); + $match[1] = str_replace( array( '<', '>' ), array( '<', '>' ), rawurldecode( $match[1] ) ); } # Handle link renaming [[foo|text]] will show link as "text" diff --git a/includes/Title.php b/includes/Title.php index 089d2a8c94..a5d9884f9a 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -411,9 +411,7 @@ class Title { // and URL-decode links if ( strpos( $m[1], '%' ) !== false ) { // Match behavior of inline link parsing here; - // don't interpret + as " " most of the time! - // It might be safe to just use rawurldecode instead, though. - $m[1] = urldecode( ltrim( $m[1], ':' ) ); + $m[1] = rawurldecode( ltrim( $m[1], ':' ) ); } $title = Title::newFromText( $m[1] ); // If the title is a redirect to bad special pages or is invalid, return null diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 8a72ba0dc6..95e0ff4b77 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -1726,14 +1726,14 @@ class Parser { # fix up urlencoded title texts if ( strpos( $m[1], '%' ) !== false ) { # Should anchors '#' also be rejected? - $m[1] = str_replace( array('<', '>'), array('<', '>'), urldecode( $m[1] ) ); + $m[1] = str_replace( array('<', '>'), array('<', '>'), rawurldecode( $m[1] ) ); } $trail = $m[3]; } elseif ( preg_match( $e1_img, $line, $m ) ) { # Invalid, but might be an image with a link in its caption $might_be_img = true; $text = $m[2]; if ( strpos( $m[1], '%' ) !== false ) { - $m[1] = urldecode( $m[1] ); + $m[1] = rawurldecode( $m[1] ); } $trail = ""; } else { # Invalid form; output directly @@ -4507,7 +4507,7 @@ class Parser { } if ( strpos( $matches[0], '%' ) !== false ) { - $matches[1] = urldecode( $matches[1] ); + $matches[1] = rawurldecode( $matches[1] ); } $tp = Title::newFromText( $matches[1] ); $nt =& $tp;