saper has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/87482


Change subject: wfExpandUrl should expand relative URLs, too
......................................................................

wfExpandUrl should expand relative URLs, too

Before this change:

with $wgServer = "http://tools.wikimedia.pl";

> var_dump(wfExpandUrl("/a", PROTO_CURRENT));
string(27) "http://tools.wikimedia.pl/a";

> var_dump(wfExpandUrl("/", PROTO_CURRENT));
string(26) "http://tools.wikimedia.pl/";

> var_dump(wfExpandUrl("z", PROTO_CURRENT));
string(1) "z"

> var_dump(wfExpandUrl("//a", PROTO_CURRENT));
string(8) "http://a";

> var_dump(wfExpandUrl("//a", PROTO_CURRENT));
string(8) "http://a";

> var_dump(wfExpandUrl("", PROTO_CURRENT));
string(0) ""

After this change:

> var_dump(wfExpandUrl("z", PROTO_CURRENT));
string(27) "http://tools.wikimedia.pl/z";

> var_dump(wfExpandUrl("", PROTO_CURRENT));
string(26) "http://tools.wikimedia.pl/";

Bug: 54950
Change-Id: Ia0397a0cfbd1d7c725864e12983c8edced261a25
---
M includes/GlobalFunctions.php
1 file changed, 5 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/82/87482/1

diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php
index b11bce9b..fb9827a 100644
--- a/includes/GlobalFunctions.php
+++ b/includes/GlobalFunctions.php
@@ -523,10 +523,13 @@
 
        if ( substr( $url, 0, 2 ) == '//' ) {
                $url = $defaultProtoWithoutSlashes . $url;
-       } elseif ( substr( $url, 0, 1 ) == '/' ) {
+       } else {
+               if ( substr( $url, 0, 1 ) != '/' ) {
+                       $url = "/" . $url;
+               }
                // If $serverUrl is protocol-relative, prepend 
$defaultProtoWithoutSlashes, otherwise leave it alone
                $url = ( $serverHasProto ? '' : $defaultProtoWithoutSlashes ) . 
$serverUrl . $url;
-       }
+       } 
 
        $bits = wfParseUrl( $url );
        if ( $bits && isset( $bits['path'] ) ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/87482
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia0397a0cfbd1d7c725864e12983c8edced261a25
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: saper <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to