-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Improper parsing of JSON string "\\" #17
Labels
Comments
Merged
Thanks for fixing this! |
Closed
Closed
GerHobbelt
pushed a commit
to GerHobbelt/nlohmann-json
that referenced
this issue
May 7, 2021
Sync Fork from Upstream Repo
925316
pushed a commit
to 925316/json
that referenced
this issue
Sep 26, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently the parser assumes if a '' is before a double quote, the double quote isn't the end of the string.
Note that there are more complicated cases like this (and their expansion) which need to be handled properly which probably will take more code to support properly: ("\"", "\") of arbitrary length. A reverse search which checks if the number of '' preceding the quote is even or odd would do it: https://github.com/nlohmann/json/blob/master/src/json.cc#L2050
Performance in backslash-heavy strings may suffer a lot though. Might be better to do a pure forward scan of the string counting backslashes as you go (Lots of memory access, but it should all be prefetched + L1 cached by current x86, x64 CPUs).
The text was updated successfully, but these errors were encountered: