r94349 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94348‎ | r94349 | r94350 >
Date:14:10, 12 August 2011
Author:dantman
Status:resolved
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/includes/interwiki/Interwiki.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/interwiki/Interwiki.php
@@ -315,11 +315,14 @@
316316 *
317317 * @param $title String: what text to put for the article name
318318 * @return String: the URL
 319+ * @note Prior to 1.19 getURL did not urlencode the $title, if you use this
 320+ * arg in an extension that supports MW earlier than 1.19 please ensure
 321+ * you wfUrlencode it when installed in earlier versions of MW.
319322 */
320323 public function getURL( $title = null ) {
321324 $url = $this->mURL;
322325 if( $title != null ) {
323 - $url = str_replace( "$1", $title, $url );
 326+ $url = str_replace( "$1", wfUrlencode( $title ), $url );
324327 }
325328 return $url;
326329 }
Index: trunk/phase3/includes/Title.php
@@ -851,15 +851,13 @@
852852 $url = $wgServer . $url;
853853 }
854854 } else {
855 - $baseUrl = $interwiki->getURL();
856 -
857 - $namespace = wfUrlencode( $this->getNsText() );
 855+ $namespace = $this->getNsText();
858856 if ( $namespace != '' ) {
859857 # Can this actually happen? Interwikis shouldn't be parsed.
860858 # Yes! It can in interwiki transclusion. But... it probably shouldn't.
861859 $namespace .= ':';
862860 }
863 - $url = str_replace( '$1', $namespace . $this->mUrlform, $baseUrl );
 861+ $url = $interwiki->getURL( $namespace . $this->getDBkey() );
864862 $url = wfAppendQuery( $url, $query );
865863 }
866864

Follow-up revisions

RevisionCommit summaryAuthorDate
r94353Followup r94349; Interwiki::getURL used `$title != null` to test if the $titl...dantman14:55, 12 August 2011

Status & tagging log