Skip to content

Improper parsing of JSON string "\\" #17

Description

@cmaloney

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions