From: Timo Tijhof Date: Tue, 13 Mar 2018 00:20:20 +0000 (-0700) Subject: CSSMin: Fix breaking of quoted urls with outer spacing X-Git-Tag: 1.34.0-rc.0~5658^2 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=5333d63cbc3d97689c3eb0ab520abc4b264dc0dd;p=lhc%2Fweb%2Fwiklou.git CSSMin: Fix breaking of quoted urls with outer spacing Bug: T189375 Change-Id: I9226ec9bd21d7dedc964fbc1dc1f0914abe458d5 --- diff --git a/includes/libs/CSSMin.php b/includes/libs/CSSMin.php index 73825e82e3..a6014b1ecd 100644 --- a/includes/libs/CSSMin.php +++ b/includes/libs/CSSMin.php @@ -420,7 +420,7 @@ class CSSMin { // is only supported in PHP 5.6. Use a getter method for now. $urlRegex = '(' . // Unquoted url - 'url\(\s*(?P[^\'"][^\?\)]+?)(?P\?[^\)]*?|)\s*\)' . + 'url\(\s*(?P[^\s\'"][^\?\)]+?)(?P\?[^\)]*?|)\s*\)' . // Single quoted url '|url\(\s*\'(?P[^\?\']+?)(?P\?[^\']*?|)\'\s*\)' . // Double quoted url diff --git a/tests/phpunit/includes/libs/CSSMinTest.php b/tests/phpunit/includes/libs/CSSMinTest.php index 02b3549a62..46bf2c6c83 100644 --- a/tests/phpunit/includes/libs/CSSMinTest.php +++ b/tests/phpunit/includes/libs/CSSMinTest.php @@ -515,7 +515,7 @@ class CSSMinTest extends MediaWikiTestCase { 'foo { background: url(//localhost/styles.css?quoted=single) }', ], [ - 'Background URL (containing parentheses; T60473)', + 'Background URL (double quoted, containing parentheses; T60473)', 'foo { background: url("//localhost/styles.css?query=(parens)") }', 'foo { background: url("//localhost/styles.css?query=(parens)") }', ], @@ -529,6 +529,11 @@ class CSSMinTest extends MediaWikiTestCase { 'foo { background: url(\'//localhost/styles.css?quote="\') }', 'foo { background: url("//localhost/styles.css?quote=\"") }', ], + [ + 'Background URL (double quoted with outer spacing)', + 'foo { background: url( "http://localhost/styles.css?quoted=double" ) }', + 'foo { background: url(http://localhost/styles.css?quoted=double) }', + ], [ 'Simple case with comments before url', 'foo { prop: /* some {funny;} comment */ url(bar.png); }',