resourceloader: Fix malformed "https:/w/resources" mapping in CSSMin
Follows-up cd54c03e86, in which I forgot a call to setScheme()
in the `isServerLess` branch.
For "server-less" URLs, we mock both schema and host, but only
strip the host. This left something I did not think was allowed
in the Net_URL2 class, which is to produce a URL that has a full
protocol and scheme, no host, and then a full path.
Moreoever, not only is this allowed by the Net_URL2 class in PHP,
modern browsers Firefox and Chrome also actually support this
and interpret it as a "domain relative" (?) URL.
Bug: T268308
Change-Id: I26ed3e5e9a6922badd979bbe6f5588e319ec3ebb
This commit is contained in:
parent
48e2e75f29
commit
af52ed44fd
2 changed files with 14 additions and 0 deletions
|
|
@ -436,6 +436,7 @@ class CSSMin {
|
|||
$ret->setScheme( false );
|
||||
}
|
||||
if ( $isServerless ) {
|
||||
$ret->setScheme( false );
|
||||
$ret->setHost( false );
|
||||
}
|
||||
return $ret->getURL();
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ class CSSMinTest extends MediaWikiIntegrationTestCase {
|
|||
return [
|
||||
[ 'url("//example.org")', [] ],
|
||||
[ 'url("https://example.org")', [] ],
|
||||
[ 'url("//example.org/x")', [] ],
|
||||
[ 'url("http://example.org/x")', [] ],
|
||||
[ 'url("https://example.org/x")', [] ],
|
||||
[ 'url("#default#")', [] ],
|
||||
[ 'url("WikiFont-Glyphs.svg#wikiglyph")', [ '/WikiFont-Glyphs.svg' ] ],
|
||||
[ 'url("#some-anchor")', [] ],
|
||||
|
|
@ -296,6 +299,16 @@ class CSSMinTest extends MediaWikiIntegrationTestCase {
|
|||
[ 'foo { prop: url(../bar.png); }', false, 'http://example.org/quux/mid/', false ],
|
||||
'foo { prop: url(http://example.org/quux/bar.png); }',
|
||||
],
|
||||
[
|
||||
'Server-less path (T268308)',
|
||||
[ 'foo { prop: url(../bar.png); }', false, '/quux/mid/', false ],
|
||||
'foo { prop: url(/quux/bar.png); }',
|
||||
],
|
||||
[
|
||||
'Protocol-relative URL',
|
||||
[ 'foo { prop: url(../bar.png); }', false, '//example.org/quux/mid/', false ],
|
||||
'foo { prop: url(//example.org/quux/bar.png); }',
|
||||
],
|
||||
[
|
||||
'Guard against stripping double slashes from query',
|
||||
[ 'foo { prop: url(bar.png?corge=//grault); }', false, 'http://example.org/quux/', false ],
|
||||
|
|
|
|||
Loading…
Reference in a new issue