Fix regression caused by r24505 for bug 10683 -- was breaking redirects to pages...
authorBrion Vibber <brion@users.mediawiki.org>
Sun, 26 Aug 2007 14:52:56 +0000 (14:52 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sun, 26 Aug 2007 14:52:56 +0000 (14:52 +0000)
Now matching parser inline link decoding; urldecode() is only run if %s are present.
This does break something that has a literal % *and* a literal +, but that already matches Parser behavior. :P
Should think about tweaking that to maybe use rawurldecode?

includes/Title.php

index e37ed07..35d57db 100644 (file)
@@ -283,7 +283,12 @@ class Title {
                        if( preg_match( '!\[{2}(.*?)(?:\||\]{2})!', $text, $m ) ) {
                                // Strip preceding colon used to "escape" categories, etc.
                                // and URL-decode links
-                               $m[1] = urldecode( ltrim( $m[1], ':' ) );
+                               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], ':' ) );
+                               }
                                $title = Title::newFromText( $m[1] );
                                // Redirects to Special:Userlogout are not permitted
                                if( $title instanceof Title && !$title->isSpecial( 'Userlogout' ) )