From a9bbf8e32bfeda2a570046e8dd696c75fe8dd4c6 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 (cherry picked from commit 5333d63cbc3d97689c3eb0ab520abc4b264dc0dd) --- RELEASE-NOTES-1.31 | 3 ++- includes/libs/CSSMin.php | 2 +- tests/phpunit/includes/libs/CSSMinTest.php | 7 ++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES-1.31 b/RELEASE-NOTES-1.31 index 4af03ee726..2758d4c567 100644 --- a/RELEASE-NOTES-1.31 +++ b/RELEASE-NOTES-1.31 @@ -130,7 +130,8 @@ production. * mediawiki/at-ease was replaced with wikimedia/at-ease. === Bug fixes in 1.31 === -* (T90902) Non-breaking space in header ID breaks anchor +* (T90902) Non-breaking space in header ID breaks anchor. +* (T189375) CSSMin now allows unquoted urls in `url()` syntax to start with a space. === Action API changes in 1.31 === * (T185058) The 'name' value to tgprop for action=query&list=tags has been diff --git a/includes/libs/CSSMin.php b/includes/libs/CSSMin.php index b538d3bb98..1ee7a3bc9d 100644 --- a/includes/libs/CSSMin.php +++ b/includes/libs/CSSMin.php @@ -421,7 +421,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