OutputPage: Ignore protocol-relative urls in transformResourcePath()
authorTimo Tijhof <krinklemail@gmail.com>
Wed, 18 Jan 2017 06:07:05 +0000 (06:07 +0000)
committerKrinkle <krinklemail@gmail.com>
Wed, 18 Jan 2017 18:15:01 +0000 (18:15 +0000)
commitd753e330a20786b8410156adfaeb0812ea85c560
treefb800ece0c1671f8c3430e995fafc2c1a51c4e32
parenta9d14289d71c71546bf48a039b238b4780445c86
OutputPage: Ignore protocol-relative urls in transformResourcePath()

transformResourcePath is only supposed to be called with something
that starts with a '/' (absolute path from document root).

While the primary caller (CSSMin) only calls this method if the path
makes sense as a local file path, ResourceLoaderSkinModule did not,
and wgLogo may be set to a full url that includes a domain.

While chance made it so that protocol-including urls were already
discarded, protocol-relative urls were mistaken for being a path
inside the file system root with a duplicate slash (e.g.
'//tmp/foo.txt', as 'foo.txt' in /fmp, instead of '/foo.txt' at
http://tmp).

This should be fixed upstream in the wikimedia/relpath library,
but workaround it for now since it really shouldn't be called
with urls in the first place.

Bug: T155310
Change-Id: I9b063f1219ddeca5cc2c8a48832cdf8c9eaffe58
includes/OutputPage.php
tests/phpunit/includes/OutputPageTest.php