From: Jakub Pawlowicz Date: Sat, 26 Jul 2014 23:08:53 +0000 (+0100) Subject: Fixes #325 - removing invalid special declarations. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=3951b93518878289bcdaaa57c123c2cca9e3b214;p=clean-css.git Fixes #325 - removing invalid special declarations. --- diff --git a/History.md b/History.md index fb1c42d6..0ce49bbf 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +[2.2.10 / 2014-xx-xx](https://github.com/GoalSmashers/clean-css/compare/v2.2.9...v2.2.10) +================== + +* Fixed issue [#325](https://github.com/GoalSmashers/clean-css/issues/325) - removing invalid @charset declarations. + [2.2.9 / 2014-07-23](https://github.com/GoalSmashers/clean-css/compare/v2.2.8...v2.2.9) ================== diff --git a/lib/clean.js b/lib/clean.js index a36ad1ef..f5cbfb75 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -189,6 +189,9 @@ var minify = function(data, callback) { data = urlsProcessor.escape(data); }); + // remove invalid special declarations + replace(/@(?:IMPORT|CHARSET) [^;]+;/g, ''); + // whitespace inside attribute selectors brackets replace(/\[([^\]]+)\]/g, function(match) { return match.replace(/\s/g, ''); diff --git a/test/unit-test.js b/test/unit-test.js index 7c0183c5..84ae6cd7 100644 --- a/test/unit-test.js +++ b/test/unit-test.js @@ -221,6 +221,10 @@ vows.describe('clean-units').addBatch({ 'charset with double line break': [ "@charset 'utf-8';" + lineBreak + lineBreak + "a{display:block}", "@charset 'utf-8';" + lineBreak + "a{display:block}" + ], + 'uppercase charset': [ + "@CHARSET 'utf-8';h1{color:red}", + 'h1{color:red}' ] }, { keepBreaks: true }), 'line breaks and important comments': cssContext({