Page MenuHomePhabricator

Relative URIs in interwiki links table causes failed redirects
Closed, ResolvedPublic

Description

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:
http://ru.wikifur.com/es:Test

This should go to:
http://es.wikifur.com/wiki/Test

However, the resulting redirect is to the following invalid URI:
http://ru.wikifur.com//es.wikifur.com/wiki/Test

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.


Version: 1.14.x
Severity: minor
URL: http://ru.wikifur.com/

attachment GlobalFunctions.php.patch ignored as obsolete

Details

Reference
bz18664

Related Objects

StatusSubtypeAssignedTask
ResolvedNone
ResolvedNone
OpenNone
ResolvedNone
DeclinedNone
DeclinedNone
ResolvedNone
ResolvedCatrope
DeclinedNone
ResolvedNone
ResolvedCatrope
ResolvedNone
ResolvedCatrope
ResolvedNone
ResolvedCatrope
ResolvedNone
ResolvedCatrope
ResolvedNone
ResolvedNone
DeclinedNone
ResolvedNone
ResolvedNone
ResolvedNone
ResolvedNone
ResolvedNone
ResolvedNone
ResolvedNone
ResolvedNone
InvalidNone
ResolvedCatrope
ResolvedNone
ResolvedCatrope
Resolvedbrion
ResolvedNone
ResolvedNone
ResolvedKrinkle
ResolvedNone
ResolvedNone
ResolvedNone
ResolvedCatrope
ResolvedNone
OpenNone
OpenNone
InvalidNone
DeclinedNone
ResolvedJackmcbarn

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:36 PM
bzimport set Reference to bz18664.
bzimport added a subscriber: Unknown Object (MLST).

Created attachment 6087
Somewhat better-formatted patch

Attached: