Skip to content

fix: handle \\ escape sequence in minify_string()#1003

Open
SummerSolsticeMuch wants to merge 1 commit intoDaveGamble:masterfrom
SummerSolsticeMuch:fix/minify-string-backslash
Open

fix: handle \\ escape sequence in minify_string()#1003
SummerSolsticeMuch wants to merge 1 commit intoDaveGamble:masterfrom
SummerSolsticeMuch:fix/minify-string-backslash

Conversation

@SummerSolsticeMuch
Copy link
Copy Markdown

Summary

  • Add \\ (escaped backslash) handling in minify_string() before the \" check

minify_string() only handled \" as an in-string escape but not \\. The sequence \\" (escaped backslash followed by closing quote) was misinterpreted as an escaped quote, causing the minifier to read past the actual string boundary and include trailing data in the output.

Test plan

  • cJSON_Minify() on {"key": "value\\"} trailing should produce {"key":"value\\"} without trailing
  • Strings with \" still minify correctly

minify_string() only handled \" as an in-string escape but not \\.
The sequence \\" (escaped backslash followed by closing quote) was
misinterpreted as an escaped quote, causing the minifier to read
past the actual string boundary and include trailing data in the
output.

Add \\ handling before the \" check so that escaped backslashes
are consumed correctly and the real closing quote is recognized.
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