Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(css): single hyphen shouldn't be treated as css identifier #1310

Merged
merged 2 commits into from May 26, 2021

Conversation

lbwa
Copy link
Contributor

@lbwa lbwa commented May 24, 2021

close #1308

CSS spec

In CSS Selector level 4:

Attribute values must be <ident-token>s or <string-token>

According to <ident-token> rules, single hyphen - without quotes is not valid ident-token which means "-" shouldn't be unwrapped as -. On the other hand, "-" is a valid <string-token> and a valid part of CSS attribute selector.

Extra helpful informations about CSS escape in w3c

cc @evanw

lbwa added 2 commits May 24, 2021 22:42
fix evanw#1308

Signed-off-by: Liu Bowen <mr_lbw@outlook.com>
Signed-off-by: Liu Bowen <mr_lbw@outlook.com>
@lbwa lbwa changed the title fix(css): single hyphen shouldn't be unwrapped in the css minification fix(css): single hyphen shouldn't be treated as css identifier May 25, 2021
@evanw
Copy link
Owner

evanw commented May 26, 2021

Thanks for the fix! Looks like the underlying reason is that utf8.DecodeRuneInString treats the end of the string as the U+FFFD replacement character which is being interpreted here as a non-ASCII code point in the "name-start code point" rule. I'll fix that part myself.

@evanw evanw merged commit 3b2fbcd into evanw:master May 26, 2021
evanw added a commit that referenced this pull request May 26, 2021
@lbwa lbwa deleted the fix-css-attr-selector branch May 26, 2021 14:17
@lbwa
Copy link
Contributor Author

lbwa commented May 26, 2021

Thanks for the fix! Looks like the underlying reason is that utf8.DecodeRuneInString treats the end of the string as the U+FFFD replacement character which is being interpreted here as a non-ASCII code point in the "name-start code point" rule. I'll fix that part myself.

Thanks for your explanation

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.

CSS minification Bug
2 participants