From: Jakub Pawlowicz Date: Wed, 24 Jun 2015 07:46:06 +0000 (+0100) Subject: Fixes #611 - an edge case in quote stripping. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=cb0cf00c6deeaf474e8c04327745f9e1366e38e7;p=clean-css.git Fixes #611 - an edge case in quote stripping. It manifested itself when rebasing to a relative or absolute path only. --- diff --git a/History.md b/History.md index 56f54f89..bd5cdb96 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,11 @@ * Fixed issue [#599](https://github.com/jakubpawlowicz/clean-css/issues/599) - support for inlined source maps. +[3.3.4 / 2015-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v3.3.3...3.3) +================== + +* Fixed issue [#611](https://github.com/jakubpawlowicz/clean-css/issues/611) - edge case in quote stripping. + [3.3.3 / 2015-06-16](https://github.com/jakubpawlowicz/clean-css/compare/v3.3.2...v3.3.3) ================== diff --git a/lib/urls/rewrite.js b/lib/urls/rewrite.js index 36db88e9..26b30f2b 100644 --- a/lib/urls/rewrite.js +++ b/lib/urls/rewrite.js @@ -73,6 +73,8 @@ function quoteFor(url) { return '"'; else if (url.indexOf('"') > -1) return '\''; + else if (/\s/.test(url)) + return '\''; else return ''; } diff --git a/test/integration-test.js b/test/integration-test.js index 06b98672..53e78ddb 100644 --- a/test/integration-test.js +++ b/test/integration-test.js @@ -1259,6 +1259,14 @@ vows.describe('integration tests') 'a{background:url("/images/blank.png")}', 'a{background:url(/images/blank.png)}' ], + 'keep quoting if whitespace': [ + 'a{background:url("/images/blank image.png")}', + 'a{background:url("/images/blank image.png")}' + ], + 'keep quoting if whitespace inside @font-face': [ + '@font-face{src:url("Helvetica Neue.eot")}', + '@font-face{src:url("Helvetica Neue.eot")}' + ], 'strip more': [ 'p{background:url("/images/blank.png")}b{display:block}a{background:url("/images/blank2.png")}', 'p{background:url(/images/blank.png)}b{display:block}a{background:url(/images/blank2.png)}' @@ -1309,6 +1317,26 @@ vows.describe('integration tests') ] }, { compatibility: 'ie8' }) ) + .addBatch( + optimizerContext('urls whitespace with url rewriting', { + 'strip single parentheses': [ + 'a{background:url("/images/blank.png")}', + 'a{background:url(/images/blank.png)}' + ], + 'strip double parentheses': [ + 'a{background:url("/images/blank.png")}', + 'a{background:url(/images/blank.png)}' + ], + 'keep quoting if whitespace': [ + 'a{background:url("/images/blank image.png")}', + 'a{background:url(\'/images/blank image.png\')}' + ], + 'keep quoting if whitespace inside @font-face': [ + '@font-face{src:url("/Helvetica Neue.eot")}', + '@font-face{src:url(\'/Helvetica Neue.eot\')}' + ] + }, { root: process.cwd(), relativeTo: process.cwd() }) + ) .addBatch( optimizerContext('urls quotes in compatibility mode', { 'keeps quotes as they are': [