From: Julien Girault Date: Thu, 27 Apr 2017 21:33:35 +0000 (-0700) Subject: CSSMin: Skip #default#behaviorName when detecting local files X-Git-Tag: 1.31.0-rc.0~2620^2 X-Git-Url: https://git.cyclocoop.org//%22?a=commitdiff_plain;h=032f0ce8cb513dd07ad77156a4630a9712654214;p=lhc%2Fweb%2Fwiklou.git CSSMin: Skip #default#behaviorName when detecting local files Bug: T162973 Change-Id: If76869910f308f8a91c73f287e7e74c214f02e9b --- diff --git a/includes/libs/CSSMin.php b/includes/libs/CSSMin.php index bba07e263b..b8d9c1d184 100644 --- a/includes/libs/CSSMin.php +++ b/includes/libs/CSSMin.php @@ -77,7 +77,12 @@ class CSSMin { $url = $match['file'][0]; // Skip fully-qualified and protocol-relative URLs and data URIs - if ( substr( $url, 0, 2 ) === '//' || parse_url( $url, PHP_URL_SCHEME ) ) { + // Also skips the rare `behavior` property specifying application's default behavior + if ( + substr( $url, 0, 2 ) === '//' || + parse_url( $url, PHP_URL_SCHEME ) || + substr( $url, 0, 9 ) === '#default#' + ) { break; } @@ -407,7 +412,12 @@ class CSSMin { // Pass thru fully-qualified and protocol-relative URLs and data URIs, as well as local URLs if // we can't expand them. - if ( self::isRemoteUrl( $url ) || self::isLocalUrl( $url ) ) { + // Also skips the rare `behavior` property specifying application's default behavior + if ( + self::isRemoteUrl( $url ) || + self::isLocalUrl( $url ) || + substr( $url, 0, 9 ) === '#default#' + ) { return $url; } diff --git a/tests/phpunit/includes/libs/CSSMinTest.php b/tests/phpunit/includes/libs/CSSMinTest.php index 42f08cc0a0..01222c61e5 100644 --- a/tests/phpunit/includes/libs/CSSMinTest.php +++ b/tests/phpunit/includes/libs/CSSMinTest.php @@ -5,6 +5,10 @@ * @author Timo Tijhof */ +/** + * @group ResourceLoader + * @group CSSMin + */ class CSSMinTest extends MediaWikiTestCase { protected function setUp() { @@ -194,6 +198,11 @@ class CSSMinTest extends MediaWikiTestCase { [ 'foo { prop: url(/w/skin/images/bar.png); }', false, 'http://example.org/quux', false ], 'foo { prop: url(http://doc.example.org/w/skin/images/bar.png); }', ], + [ + "Don't barf at behavior: url(#default#behaviorName) - T162973", + [ 'foo { behavior: url(#default#bar); }', false, '/w/', false ], + 'foo { behavior: url("#default#bar"); }', + ], ]; }