bug 18664, bug 19270: Relative URIs in interwiki table break things (in general:...
authorChad Horohoe <demon@users.mediawiki.org>
Wed, 17 Mar 2010 00:21:52 +0000 (00:21 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Wed, 17 Mar 2010 00:21:52 +0000 (00:21 +0000)
RELEASE-NOTES
includes/GlobalFunctions.php
includes/HttpFunctions.php

index ebcd6fc..1045b40 100644 (file)
@@ -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
index 69cae20..36860e3 100644 (file)
@@ -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 {
index d5dc243..8355ec1 100644 (file)
@@ -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'] ) ) {