Skip to content

Commit

Permalink
fix #1483: UTF-8 and utf-8 are the same @charset
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Aug 1, 2021
1 parent fe3659e commit 4d815e2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/css_parser/css_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ func (p *parser) parseAtRule(context atRuleContext) css_ast.R {
p.expect(css_lexer.TWhitespace)
if p.peek(css_lexer.TString) {
encoding := p.decoded()
if encoding != "UTF-8" {
if !strings.EqualFold(encoding, "UTF-8") {
p.log.AddRangeWarning(&p.tracker, p.current().Range,
fmt.Sprintf("\"UTF-8\" will be used instead of unsupported charset %q", encoding))
}
Expand Down
3 changes: 3 additions & 0 deletions internal/css_parser/css_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,9 @@ func TestAtCharset(t *testing.T) {
expectPrinted(t, "@charset \"UTF-8\";", "@charset \"UTF-8\";\n")
expectPrinted(t, "@charset 'UTF-8';", "@charset \"UTF-8\";\n")

expectParseError(t, "@charset \"utf-8\";", "")
expectParseError(t, "@charset \"Utf-8\";", "")
expectParseError(t, "@charset \"UTF-8\";", "")
expectParseError(t, "@charset \"US-ASCII\";", "<stdin>: warning: \"UTF-8\" will be used instead of unsupported charset \"US-ASCII\"\n")
expectParseError(t, "@charset;", "<stdin>: warning: Expected whitespace but found \";\"\n")
expectParseError(t, "@charset ;", "<stdin>: warning: Expected string token but found \";\"\n")
Expand Down

0 comments on commit 4d815e2

Please sign in to comment.