tgockel / json-voorhees

A killer modern C++ library for interacting with JSON.
http://tgockel.github.io/json-voorhees/
Apache License 2.0
128 stars 18 forks source link

Invalid `\uxxxx` in a parsed string throws `range_error` #48

Closed sth closed 9 years ago

sth commented 9 years ago

If a json string is parsed and contains a string literal with a \u that is not followed by hex digits, a range_error is thrown by from_hex_digit, but the surrounding code doesn't expect that.

The parse_string() function, which calls the string decoding, only handles decode_error, not range_error. Probably this function should handle range_error in the same way, or string_decode() should already convert it into a decode_error when parsing the \u escape.

The exception can for example be triggered by this:

"\"\\uzzzz\""_json
tgockel commented 9 years ago

Agreed -- it makes more sense to have from_hex_digit throw a decode_error here.

tgockel commented 9 years ago

Fixed.