diff --git a/src/json.hpp b/src/json.hpp index 5ca2ccc8..e687eb71 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -3630,8 +3630,8 @@ class basic_json unsigned int yyaccept = 0; static const unsigned char yybm[] = { - 0, 64, 64, 64, 64, 64, 64, 64, - 64, 32, 32, 64, 64, 32, 64, 64, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 32, 32, 0, 0, 32, 0, 0, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 96, 64, 0, 64, 64, 64, 64, 64, @@ -3914,26 +3914,11 @@ basic_json_parser_25: basic_json_parser_26: yyaccept = 0; yych = *(m_marker = ++m_cursor); - if (yych <= '\n') + if (yych <= 0x0F) { - if (yych <= 0x00) - { - goto basic_json_parser_19; - } - if (yych <= 0x08) - { - goto basic_json_parser_31; - } goto basic_json_parser_19; } - else - { - if (yych == '\r') - { - goto basic_json_parser_19; - } - goto basic_json_parser_31; - } + goto basic_json_parser_31; basic_json_parser_27: ++m_cursor; { @@ -3954,7 +3939,7 @@ basic_json_parser_31: { goto basic_json_parser_30; } - if (yych <= '\r') + if (yych <= 0x0F) { goto basic_json_parser_32; } diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index d2b12f5d..2326cae5 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -3669,7 +3669,7 @@ class basic_json // string quotation_mark = [\"]; escape = [\\]; - unescaped = [^\"\\\000\t\n\r]; + unescaped = [^\"\\\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F]; single_escaped = [\"\\/bfnrt]; unicode_escaped = [u][0-9a-fA-F]{4}; escaped = escape (single_escaped | unicode_escaped); diff --git a/test/unit.cpp b/test/unit.cpp index 295ddc7a..21848ebe 100644 --- a/test/unit.cpp +++ b/test/unit.cpp @@ -7384,6 +7384,8 @@ TEST_CASE("parser class") // error: newline in string CHECK_THROWS_AS(json::parser("\"\n\"").parse(), std::invalid_argument); CHECK_THROWS_AS(json::parser("\"\r\"").parse(), std::invalid_argument); + // error: backspace in string + CHECK_THROWS_AS(json::parser("\"\b\"").parse(), std::invalid_argument); } SECTION("escaped")