tdewolff / parse

Go parsers for web formats
MIT License
413 stars 65 forks source link

Rule case will be modified when parse css #106

Closed ttttmr closed 1 year ago

ttttmr commented 1 year ago

https://github.com/tdewolff/parse/blob/91901180122e1211ba489e7eac0ad991c0da38b2/css/parse.go#L235 https://github.com/tdewolff/parse/blob/91901180122e1211ba489e7eac0ad991c0da38b2/css/parse.go#L381

There are two ToLower calls here, which will modify the case of the original data when parsing

I don't think it should be modified, especially when the data is not css, some strings in the data may be modified after calling parse

You may need to use Copy like here https://github.com/tdewolff/parse/blob/91901180122e1211ba489e7eac0ad991c0da38b2/html/lex.go#L198

or simply delete this call (I am not very proficient in css, and I don't really understand why it needs to be lowercased here)

tdewolff commented 1 year ago

Thank, should be fixed now. Principally it's used to improve GZIP compression, but I've added Copy to avoid modifying the original.

tdewolff commented 1 year ago

Fixed in https://github.com/tdewolff/parse/commit/98cf927e40837df9e1a0536cb23c5c2e7e694786