From 660e79ffe99da64f495191c609b1c37addfd70ff Mon Sep 17 00:00:00 2001 From: Jakub Pawlowicz Date: Sat, 2 Aug 2014 10:41:12 +0100 Subject: [PATCH] Refixes #325 - invalid charset declarations. * All incorrect, non-lowercase charsets are being now removed. * Removes stripping @IMPORT declarations. --- History.md | 1 + lib/clean.js | 4 +++- test/unit-test.js | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 8db3e3da..c3c79b34 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,7 @@ * Fixed issue with tokenizer removing first selector after an unknown @ rule. * Fixed issue [#329](https://github.com/GoalSmashers/clean-css/issues/329) - font shorthands incorrectly processed. +* Refixed issue [#325](https://github.com/GoalSmashers/clean-css/issues/325) - invalid charset declarations. [2.2.11 / 2014-07-28](https://github.com/GoalSmashers/clean-css/compare/v2.2.10...v2.2.11) ================== diff --git a/lib/clean.js b/lib/clean.js index 88434137..704c2d8d 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -190,7 +190,9 @@ var minify = function(data, callback) { }); // remove invalid special declarations - replace(/@(?:IMPORT|CHARSET) [^;]+;/g, ''); + replace(/@charset [^;]+;/ig, function (match) { + return match.indexOf('@charset') > -1 ? match : ''; + }); // whitespace inside attribute selectors brackets replace(/\[([^\]]+)\]/g, function(match) { diff --git a/test/unit-test.js b/test/unit-test.js index accc8b16..fc5ba6bd 100644 --- a/test/unit-test.js +++ b/test/unit-test.js @@ -225,6 +225,10 @@ vows.describe('clean-units').addBatch({ 'uppercase charset': [ "@CHARSET 'utf-8';h1{color:red}", 'h1{color:red}' + ], + 'mixed case charset': [ + "@chArSET 'utf-8';h1{color:red}", + 'h1{color:red}' ] }, { keepBreaks: true }), 'line breaks and important comments': cssContext({ -- 2.34.1