From 4adbf18589af98775c52f6cab8c2825c84221687 Mon Sep 17 00:00:00 2001 From: enricodias Date: Mon, 20 Apr 2020 10:55:08 -0300 Subject: [PATCH 1/2] Add tests for #258 --- tests/css/CSSTest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/css/CSSTest.php b/tests/css/CSSTest.php index 76f80aba..210e97f1 100644 --- a/tests/css/CSSTest.php +++ b/tests/css/CSSTest.php @@ -759,6 +759,24 @@ public function dataProvider() '@import url(http://minify.dev/?a=1&b=some/*lala*/thing);p{color:red}body{font-family:sans-serif}', ); + // https://github.com/matthiasmullie/minify/pull/258 + $tests[] = array( + 'color:white;', + 'color:#fff;', + ); + $tests[] = array( + 'color:black;', + 'color:#000;', + ); + $tests[] = array( + 'background:white;', + 'background:#fff;', + ); + $tests[] = array( + 'background:black;', + 'background:#000;', + ); + // https://github.com/matthiasmullie/minify/issues/259 $tests[] = array( '#layout-newsletter-change .unsubscribe :checked + label .circle, #layout-newsletter-change .pause : checked + label .circle { color: white }', From bb71fad0b6df15bd83623a00f5377b78895ff5c2 Mon Sep 17 00:00:00 2001 From: enricodias Date: Mon, 20 Apr 2020 11:30:37 -0300 Subject: [PATCH 2/2] prevent color code changes in font-family --- src/CSS.php | 2 +- tests/css/CSSTest.php | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/CSS.php b/src/CSS.php index 89fcf1bb..05956e19 100644 --- a/src/CSS.php +++ b/src/CSS.php @@ -525,7 +525,7 @@ protected function shortenColors($content) ); return preg_replace_callback( - '/(?<=[: ])('.implode('|', array_keys($colors)).')(?=[; }])/i', + '/(?<=[:])(?