Fixes #325 - removing invalid special declarations.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Sat, 26 Jul 2014 23:08:53 +0000 (00:08 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Sun, 27 Jul 2014 13:30:55 +0000 (14:30 +0100)
History.md
lib/clean.js
test/unit-test.js

index fb1c42d..0ce49bb 100644 (file)
@@ -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)
 ==================
 
index a36ad1e..f5cbfb7 100644 (file)
@@ -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, '');
index 7c0183c..84ae6cd 100644 (file)
@@ -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({