From 3951b93518878289bcdaaa57c123c2cca9e3b214 Mon Sep 17 00:00:00 2001 From: Jakub Pawlowicz Date: Sun, 27 Jul 2014 00:08:53 +0100 Subject: [PATCH] Fixes #325 - removing invalid special declarations. --- History.md | 5 +++++ lib/clean.js | 3 +++ test/unit-test.js | 4 ++++ 3 files changed, 12 insertions(+) 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({ -- 2.34.1