diff --git a/includes/libs/CSSMin.php b/includes/libs/CSSMin.php index 74278b212f3..b01a8f613e5 100644 --- a/includes/libs/CSSMin.php +++ b/includes/libs/CSSMin.php @@ -436,6 +436,7 @@ class CSSMin { $ret->setScheme( false ); } if ( $isServerless ) { + $ret->setScheme( false ); $ret->setHost( false ); } return $ret->getURL(); diff --git a/tests/phpunit/includes/libs/CSSMinTest.php b/tests/phpunit/includes/libs/CSSMinTest.php index 40096a9bdd3..46dc27fbf82 100644 --- a/tests/phpunit/includes/libs/CSSMinTest.php +++ b/tests/phpunit/includes/libs/CSSMinTest.php @@ -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 ],