From: Jakub Pawlowicz Date: Sat, 1 Mar 2014 09:05:55 +0000 (+0000) Subject: Fixes #250 - correctly handle JSON data in quotations. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=b02a1d0f7f404dc24c94b6f6a8d16db93479e11f;p=clean-css.git Fixes #250 - correctly handle JSON data in quotations. It's a quick fix. Proper one comes to master soon. --- diff --git a/History.md b/History.md index a8ebdd74..f63e9546 100644 --- a/History.md +++ b/History.md @@ -4,6 +4,11 @@ * Adds a better non-adjacent optimizer compatible with the upcoming new property optimizer. * Fixed issue [#247](https://github.com/GoalSmashers/clean-css/issues/247) - removes deprecated `selectorsMergeMode` switch. +[2.1.4 / 2014-xx-xx](https://github.com/GoalSmashers/clean-css/compare/v2.1.3...v2.1.4) +================== + +* Fixed issue [#250](https://github.com/GoalSmashers/clean-css/issues/250) - correctly handle JSON data in quotations. + [2.1.3 / 2014-02-26](https://github.com/GoalSmashers/clean-css/compare/v2.1.2...v2.1.3) ================== diff --git a/lib/clean.js b/lib/clean.js index ed00f51a..0f311799 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -144,6 +144,9 @@ var minify = function(data, callback) { // strip parentheses in animation & font names replace(/(animation|animation\-name|font|font\-family):([^;}]+)/g, function(match, propertyName, def) { + if (def.indexOf('\'{') === 0) + return match; + return propertyName + ':' + def.replace(/['"]([a-zA-Z][a-zA-Z\d\-_]+)['"]/g, '$1'); }); diff --git a/test/unit-test.js b/test/unit-test.js index 473a303f..aa882842 100644 --- a/test/unit-test.js +++ b/test/unit-test.js @@ -806,7 +806,8 @@ path)}', 'a{background:url("/very/long/\ path")}', 'a{background:url(/very/long/path)}' - ] + ], + 'do not remove quotation from enclosed JSON (weird, I know)': "p{font-family:'{ \"current\" : \"large\", \"all\" : [\"small\", \"medium\", \"large\"], \"position\" : 2 }'}" }), 'urls rewriting - no root or target': cssContext({ 'no @import': 'a{background:url(test/data/partials/extra/down.gif) 0 0 no-repeat}',