Update Interwiki::getURL's first argument so that it's properly urlencoded when repla...
authorDaniel Friesen <dantman@users.mediawiki.org>
Fri, 12 Aug 2011 14:10:37 +0000 (14:10 +0000)
committerDaniel Friesen <dantman@users.mediawiki.org>
Fri, 12 Aug 2011 14:10:37 +0000 (14:10 +0000)
Scanning all of core and all the extensions we have in svn, it doesn't look like anyone makes any calls to Interwiki::getURL using the argument so this should be safe enough to clean up the api.
Also update Title::getFullURL to make use of the first arg now.

includes/Title.php
includes/interwiki/Interwiki.php

index ed6e735..a0af584 100644 (file)
@@ -851,15 +851,13 @@ class Title {
                                $url = $wgServer . $url;
                        }
                } else {
-                       $baseUrl = $interwiki->getURL();
-
-                       $namespace = wfUrlencode( $this->getNsText() );
+                       $namespace = $this->getNsText();
                        if ( $namespace != '' ) {
                                # Can this actually happen? Interwikis shouldn't be parsed.
                                # Yes! It can in interwiki transclusion. But... it probably shouldn't.
                                $namespace .= ':';
                        }
-                       $url = str_replace( '$1', $namespace . $this->mUrlform, $baseUrl );
+                       $url = $interwiki->getURL( $namespace . $this->getDBkey() );
                        $url = wfAppendQuery( $url, $query );
                }
 
index 880f79a..1ba0f10 100644 (file)
@@ -315,11 +315,14 @@ class Interwiki {
         *
         * @param $title String: what text to put for the article name
         * @return String: the URL
+        * @note Prior to 1.19 getURL did not urlencode the $title, if you use this
+        *       arg in an extension that supports MW earlier than 1.19 please ensure
+        *       you wfUrlencode it when installed in earlier versions of MW.
         */
        public function getURL( $title = null ) {
                $url = $this->mURL;
                if( $title != null ) {
-                       $url = str_replace( "$1", $title, $url );
+                       $url = str_replace( "$1", wfUrlencode( $title ), $url );
                }
                return $url;
        }