Permalink
Browse files

Warn about @charset rules only if they specify anything but utf-8

  • Loading branch information...
1 parent a26822e commit 6b9af2b058ce005d4af956b5161812d356aaa092 @Slava Slava committed Feb 5, 2014
Showing with 9 additions and 2 deletions.
  1. +9 −2 packages/minifiers/minifiers.js
@@ -32,8 +32,15 @@ CssTools = {
_.each(cssAsts, function (ast) {
// Pick only the imports from the beginning of file ignoring @charset
// rules as every file is assumed to be in UTF-8.
- if (_.any(ast.stylesheet.rules, rulesPredicate("charset"))) {
- warnCb(ast.filename, "@charset rules in this file will be ignored as Meteor supports only utf-8 at the moment.");
+ var charsetRules = _.filter(ast.stylesheet.rules,
+ rulesPredicate("charset"));
+
+ if (_.any(charsetRules, function (rule) {
+ // According to MDN, only 'UTF-8' and "UTF-8" are the correct encoding
+ // directives representing UTF-8.
+ return ! /^(['"])UTF-8\1$/.test(rule.charset);
+ })) {
+ warnCb(ast.filename, "@charset rules in this file will be ignored as UTF-8 is the only encoding supported");
}
ast.stylesheet.rules = _.reject(ast.stylesheet.rules,

0 comments on commit 6b9af2b

Please sign in to comment.