(Bug 26410) In an internal link, a plus sign is treated as a space if the link
authorBrian Wolff <bawolff@users.mediawiki.org>
Fri, 24 Dec 2010 09:53:08 +0000 (09:53 +0000)
committerBrian Wolff <bawolff@users.mediawiki.org>
Fri, 24 Dec 2010 09:53:08 +0000 (09:53 +0000)
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.

RELEASE-NOTES
includes/Linker.php
includes/Title.php
includes/parser/Parser.php

index 0304627..b2823b0 100644 (file)
@@ -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
index 70d2b8a..2d06740 100644 (file)
@@ -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( '&lt;', '&gt;' ), urldecode( $match[1] ) );
+                       $match[1] = str_replace( array( '<', '>' ), array( '&lt;', '&gt;' ), rawurldecode( $match[1] ) );
                }
 
                # Handle link renaming [[foo|text]] will show link as "text"
index 089d2a8..a5d9884 100644 (file)
@@ -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
index 8a72ba0..95e0ff4 100644 (file)
@@ -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('&lt;', '&gt;'), urldecode( $m[1] ) );
+                                       $m[1] = str_replace( array('<', '>'), array('&lt;', '&gt;'), 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;