Skip to content

Commit

Permalink
CSS: fix unicode range parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
tdewolff committed Mar 15, 2021
1 parent c8eccbb commit 6f64ef6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions css/lex.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ func (l *Lexer) consumeUnicodeRangeToken() bool {

// either a minus or a question mark or the end is expected
if l.consumeByte('-') {
if 6 < k {
if k == 0 || 6 < k {
l.r.Rewind(mark)
return false
}
Expand All @@ -513,7 +513,7 @@ func (l *Lexer) consumeUnicodeRangeToken() bool {
k++
}
}
if 6 < k {
if k == 0 || 6 < k {
l.r.Rewind(mark)
return false
}
Expand Down
2 changes: 1 addition & 1 deletion css/lex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func TestTokens(t *testing.T) {
{" \n\r\n\r\"\\\r\n\\\r\"", TTs{StringToken}, []string{"\"\\\r\n\\\r\""}},
{"U+?????? U+ABCD?? U+ABC-DEF", TTs{UnicodeRangeToken, UnicodeRangeToken, UnicodeRangeToken}, []string{"U+??????", "U+ABCD??", "U+ABC-DEF"}},
{"U+? U+A?", TTs{UnicodeRangeToken, UnicodeRangeToken}, []string{"U+?", "U+A?"}},
{"U+ABCDEF?", TTs{IdentToken, DelimToken, IdentToken, DelimToken}, []string{"U", "+", "ABCDEF", "?"}},
{"U+ U+ABCDEF?", TTs{IdentToken, DelimToken, IdentToken, DelimToken, IdentToken, DelimToken}, []string{"U", "+", "U", "+", "ABCDEF", "?"}},
{"-5.23 -moz", TTs{NumberToken, IdentToken}, []string{"-5.23", "-moz"}},
{"()", TTs{LeftParenthesisToken, RightParenthesisToken}, []string{"(", ")"}},
{"url( //url\n )", TTs{URLToken}, []string{"url( //url\n )"}},
Expand Down

0 comments on commit 6f64ef6

Please sign in to comment.