Skip to content

Conversation

@cscott
Copy link
Contributor

@cscott cscott commented Jan 30, 2016

The CSS escape syntax is not the same as JavaScript escapes -- and besides, using eval is evil. Write a proper parser (and serializer) for CSS strings with escape sequences.

@cscott cscott mentioned this pull request Jan 30, 2016
@cscott
Copy link
Contributor Author

cscott commented Feb 2, 2016

@XhmikosR this one's pretty important, too, since it eliminates an eval in the source code (in addition to making the parsing actually match the CSS spec).

@cscott
Copy link
Contributor Author

cscott commented Feb 2, 2016

Pinging @frvge on this patch.

@cscott cscott force-pushed the parse-quoted branch 2 times, most recently from 81c284b to 0eac1e6 Compare February 3, 2016 18:36
@cscott
Copy link
Contributor Author

cscott commented Feb 3, 2016

Found some issues with tokenization of strings containing escaped newlines; rebased & fixed them (and added better test cases).

The CSS escape syntax is not the same as JavaScript escapes -- and
besides, using `eval` is evil.  Write a proper parser (and serializer)
for CSS strings with escape sequences.

Regular expressions in this patch based on those found in
https://www.w3.org/TR/CSS21/grammar.html#scanner
@cscott cscott changed the title Properly parse CSS strings with escape sequences. Properly parse CSS strings/URLs/identifiers with escape sequences. Feb 5, 2016
@cscott
Copy link
Contributor Author

cscott commented Feb 5, 2016

Rebased and added a patch to improve escape sequence handling in identifiers and URLs.

Implement proper parsing of escape sequences in unquoted URL function
arguments, and ensure escape sequences in quoted URLs are properly
translated when creating a PropertyValuePart.

The secondary parsing in PropertyValuePart to assign a type string
can fail when the identifier contains escape sequences.  Pass in a
`hint` object based on the original token emitted from the lexer to
disambiguate in these cases.
@XhmikosR XhmikosR added this to the v0.2.6 milestone Feb 6, 2016
XhmikosR added a commit that referenced this pull request Feb 6, 2016
Properly parse CSS strings/URLs/identifiers with escape sequences.
@XhmikosR XhmikosR merged commit 889093c into CSSLint:master Feb 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants