From 3e2fd810d22aa6e9f7972af94d74dba4eb0959f8 Mon Sep 17 00:00:00 2001 From: Trevor Parscal Date: Tue, 10 Jun 2014 22:04:40 +0000 Subject: [PATCH 1/1] Revert "Fix "CSSMin url() value remapping not working in certain obscure cases"" This reverts commit fa1053a16a5b3ff2004f6c06c69e87f8570a35d7. Breaks CSS output, making the skin and extensions look unstyled. Change-Id: I297150f775dd5559f91f2c9c25c64b134459c6b6 --- includes/libs/CSSMin.php | 7 ++--- tests/phpunit/includes/libs/CSSMinTest.php | 35 ---------------------- 2 files changed, 3 insertions(+), 39 deletions(-) diff --git a/includes/libs/CSSMin.php b/includes/libs/CSSMin.php index 605e09434e..10277e6e31 100644 --- a/includes/libs/CSSMin.php +++ b/includes/libs/CSSMin.php @@ -203,12 +203,11 @@ class CSSMin { $remote = substr( $remote, 0, -1 ); } - // Note: This will correctly handle cases where ';', '{' or '}' appears - // in a css block comment (/* ... */). All other occurrences, e.g. in - // quoted strings, will not be handled correctly. You are advised + // Note: This will not correctly handle cases where ';', '{' or '}' + // appears in the rule itself, e.g. in a quoted string. You are advised // not to use such characters in file names. We also match start/end of // the string to be consistent in edge-cases ('@import url(…)'). - $pattern = '/(?:^|[;{])\K(?:\/\*.*?\*\/|[^;{}])*' . CSSMin::URL_REGEX . '(?:\/\*.*?\*\/|[^;}])*(?=[;}]|$)/'; + $pattern = '/(?:^|[;{])\K[^;{}]*' . CSSMin::URL_REGEX . '[^;}]*(?=[;}]|$)/'; return preg_replace_callback( $pattern, diff --git a/tests/phpunit/includes/libs/CSSMinTest.php b/tests/phpunit/includes/libs/CSSMinTest.php index a6f7914412..bb5e398c6a 100644 --- a/tests/phpunit/includes/libs/CSSMinTest.php +++ b/tests/phpunit/includes/libs/CSSMinTest.php @@ -291,41 +291,6 @@ class CSSMinTest extends MediaWikiTestCase { '@import url(//localhost/styles.css?query=yes)', '@import url(//localhost/styles.css?query=yes)', ), - array( - 'Simple case with comments before url', - 'foo { prop: /* some {funny;} comment */ url(bar.png); }', - 'foo { prop: /* some {funny;} comment */ url(http://localhost/w/bar.png); }', - ), - array( - 'Simple case with comments after url', - 'foo { prop: url(red.gif)/* some {funny;} comment */ ; }', - 'foo { prop: url(http://localhost/w/red.gif?timestamp)/* some {funny;} comment */ ; }', - ), - array( - 'Embedded file with comment before url', - 'foo { /* @embed */ background: /* some {funny;} comment */ url(red.gif); }', - "foo { background: /* some {funny;} comment */ url($red); background: /* some {funny;} comment */ url(http://localhost/w/red.gif?timestamp)!ie; }", - ), - array( - 'Embedded file with comment after url', - 'foo { /* @embed */ background: url(red.gif) /* some {funny;} comment */; }', - "foo { background: url($red) /* some {funny;} comment */; background: url(http://localhost/w/red.gif?timestamp) /* some {funny;} comment */!ie; }", - ), - array( - 'Embedded file with comment outside the rule', - 'foo { /* @embed */ background: url(red.gif); /* some {funny;} comment */ }', - "foo { background: url($red); background: url(http://localhost/w/red.gif?timestamp)!ie; /* some {funny;} comment */ }", - ), - array( - 'Rule with two urls, each with comments', - '{ background: /*asd*/ url(something.png); background: /*jkl*/ url(something.png); }', - '{ background: /*asd*/ url(http://localhost/w/something.png); background: /*jkl*/ url(http://localhost/w/something.png); }', - ), - array( - 'Sanity check for offending line from jquery.ui.theme.css (bug 60077)', - '.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #d3d3d3/*{borderColorDefault}*/; background: #e6e6e6/*{bgColorDefault}*/ url(images/ui-bg_glass_75_e6e6e6_1x400.png)/*{bgImgUrlDefault}*/ 50%/*{bgDefaultXPos}*/ 50%/*{bgDefaultYPos}*/ repeat-x/*{bgDefaultRepeat}*/; font-weight: normal/*{fwDefault}*/; color: #555555/*{fcDefault}*/; }', - '.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #d3d3d3/*{borderColorDefault}*/; background: #e6e6e6/*{bgColorDefault}*/ url(http://localhost/w/images/ui-bg_glass_75_e6e6e6_1x400.png)/*{bgImgUrlDefault}*/ 50%/*{bgDefaultXPos}*/ 50%/*{bgDefaultYPos}*/ repeat-x/*{bgDefaultRepeat}*/; font-weight: normal/*{fwDefault}*/; color: #555555/*{fcDefault}*/; }', - ), ); } -- 2.20.1