From 5333d63cbc3d97689c3eb0ab520abc4b264dc0dd Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Mon, 12 Mar 2018 17:20:20 -0700 Subject: [PATCH] CSSMin: Fix breaking of quoted urls with outer spacing Bug: T189375 Change-Id: I9226ec9bd21d7dedc964fbc1dc1f0914abe458d5 --- includes/libs/CSSMin.php | 2 +- tests/phpunit/includes/libs/CSSMinTest.php | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) 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); }', -- 2.20.1