From 2b4ff9dfaa7037967edfeb0e3c1556ec8075a5af Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Wed, 17 Mar 2010 00:21:52 +0000 Subject: [PATCH] bug 18664, bug 19270: Relative URIs in interwiki table break things (in general: fix wfExpandUrl() so it handles protocol-relative URIs) --- RELEASE-NOTES | 2 ++ includes/GlobalFunctions.php | 13 ++++++++----- includes/HttpFunctions.php | 1 + 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index ebcd6fc04f..1045b40c76 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -50,6 +50,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 22747) "Reveal my e-mail address in notification e-mails" preference is now only displayed when relevant * (bug 22772) {{#special:}} parser function now works with subpages +* (bug 18664) Relative URIs in interwiki links cause failed redirects +* (bug 19270) Relative URIs in interwiki links break interwiki transclusion == API changes in 1.17 == * (bug 22738) Allow filtering by action type on query=logevent diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 69cae2053a..36860e38b0 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1409,16 +1409,19 @@ function wfAppendQuery( $url, $query ) { /** * Expand a potentially local URL to a fully-qualified URL. Assumes $wgServer - * is correct. Also doesn't handle any type of relative URL except one - * starting with a single "/": this won't work with current-path-relative URLs - * like "subdir/foo.html", protocol-relative URLs like - * "//en.wikipedia.org/wiki/", etc. TODO: improve this! + * and $wgProto are correct. + * + * @todo this won't work with current-path-relative URLs + * like "subdir/foo.html", etc. * * @param $url String: either fully-qualified or a local path + query * @return string Fully-qualified URL */ function wfExpandUrl( $url ) { - if( substr( $url, 0, 1 ) == '/' ) { + if( substr( $url, 0, 2 ) == '//' ) { + global $wgProto; + return $wgProto . ':' . $url; + } elseif( substr( $url, 0, 1 ) == '/' ) { global $wgServer; return $wgServer . $url; } else { diff --git a/includes/HttpFunctions.php b/includes/HttpFunctions.php index d5dc2431f1..8355ec188a 100644 --- a/includes/HttpFunctions.php +++ b/includes/HttpFunctions.php @@ -27,6 +27,7 @@ class Http { * @returns mixed (bool)false on failure or a string on success */ public static function request( $method, $url, $options = array() ) { + $url = wfExpandUrl( $url ); wfDebug( "HTTP: $method: $url" ); $options['method'] = strtoupper( $method ); if ( !isset( $options['timeout'] ) ) { -- 2.20.1