From d5dfd2b066b81aa8636276fc1e5dac467b021bd0 Mon Sep 17 00:00:00 2001 From: Daniel Friesen Date: Fri, 12 Aug 2011 14:10:37 +0000 Subject: [PATCH] Update Interwiki::getURL's first argument so that it's properly urlencoded when replacements are made. 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 | 6 ++---- includes/interwiki/Interwiki.php | 5 ++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/includes/Title.php b/includes/Title.php index ed6e735b51..a0af584d11 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -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 ); } diff --git a/includes/interwiki/Interwiki.php b/includes/interwiki/Interwiki.php index 880f79a289..1ba0f106d8 100644 --- a/includes/interwiki/Interwiki.php +++ b/includes/interwiki/Interwiki.php @@ -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; } -- 2.20.1