Skip to content

fix escaped backslash handling in minify_string - #1101

Open
nabhan06 wants to merge 1 commit into
DaveGamble:masterfrom
nabhan06:minify-escaped-backslash
Open

nabhan06 wants to merge 1 commit into
DaveGamble:masterfrom
nabhan06:minify-escaped-backslash

Conversation

@nabhan06

Copy link
Copy Markdown

minify_string only treats a backslash as the start of an escape when the next byte is a double quote, so a string value that ends in an escaped backslash (for example the value "\") is misread: the second backslash and the real closing quote are taken as an escaped quote and consumed, and the scanner keeps going past the end of the string. Everything after it, including comments and whitespace that minify is meant to strip, is then copied verbatim until the next quote. For input like {"p":"\" /* c */ , "q":1} the minified output keeps the comment and no longer parses.

Treat any non-NUL byte after a backslash as an escaped character so the pair is copied and skipped together. Added a regression test in tests/minify_tests.c covering an escaped backslash right before the closing quote.

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.

1 participant