Support protocol-relative URLs in wfExpandUrl (includes/GlobalFunctions.php 1.14.0)
We use protocol-relative URIs like "//es.wikifur.com" in our interwiki table to reduce the size of the output - all our sites are on http:, so there's no need for the language links to have http: at the front.
This works great in pages, but fails when people use a URL like this:
This should go to:
However, the resulting redirect is to the following invalid URI:
I tracked this down to wfExpandUrl in includes/GlobalFunctions.php, which tests for $url starting with '/' (i.e. site-relative URIs) and just returns the URI in this case. Having '//' at the front was probably not considered.
A patch is attached which attempts to work around this. It also provide for absolute URIs rather than relative ones by extracting the current protocol from $wgServer. Absolute URIs are required in Location: by the HTTP 1.1 standard, though most browsers will accept relative ones (Lynx grumbles about it).
There may be a better way to do it, or a better place to patch; I did not find where this code is called from.
attachment GlobalFunctions.php.patch ignored as obsolete