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

Improper parsing of JSON string "\\" #17

Closed
cmaloney opened this issue Jan 6, 2015 · 1 comment
Closed

Improper parsing of JSON string "\\" #17

cmaloney opened this issue Jan 6, 2015 · 1 comment

Comments

@cmaloney
Copy link

cmaloney commented Jan 6, 2015

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).

nlohmann added a commit that referenced this issue Jan 9, 2015
@cmaloney
Copy link
Author

Thanks for fixing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants