Added broken_nul_parser to preserve previous behaviour

This commit is contained in:
Peter Conrad 2018-03-07 15:26:30 +01:00 committed by Peter Conrad
parent 90137d400d
commit 2bacd5fda8
2 changed files with 5 additions and 1 deletions

View file

@ -21,8 +21,9 @@ namespace fc
#ifdef WITH_EXOTIC_JSON_PARSERS #ifdef WITH_EXOTIC_JSON_PARSERS
strict_parser = 1, strict_parser = 1,
relaxed_parser = 2, relaxed_parser = 2,
legacy_parser_with_string_doubles = 3 legacy_parser_with_string_doubles = 3,
#endif #endif
broken_nul_parser = 4
}; };
enum output_formatting enum output_formatting
{ {

View file

@ -441,6 +441,9 @@ namespace fc
case EOF: case EOF:
FC_THROW_EXCEPTION( eof_exception, "unexpected end of file" ); FC_THROW_EXCEPTION( eof_exception, "unexpected end of file" );
case 0: case 0:
if( parser_type == fc::json::broken_nul_parser )
return variant();
[[fallthrough]];
default: default:
FC_THROW_EXCEPTION( parse_error_exception, "Unexpected char '${c}' in \"${s}\"", FC_THROW_EXCEPTION( parse_error_exception, "Unexpected char '${c}' in \"${s}\"",
("c", c)("s", stringFromToken(in)) ); ("c", c)("s", stringFromToken(in)) );