Allow \/ in a json string

This commit is contained in:
Jay Berkenbilt 2022-02-25 11:42:50 -05:00
parent e7ecc348f9
commit 36794a60cf
4 changed files with 12 additions and 3 deletions

View File

@ -1,3 +1,8 @@
2022-02-25 Jay Berkenbilt <ejb@ql.org>
* Bug fix in JSON parser: accept \/ in a string as valid input per
JSON spec even though we don't translate / to \/ on output.
2022-02-22 Jay Berkenbilt <ejb@ql.org>
* Recognize PDF strings explicitly marked as UTF-8 as allowed by

View File

@ -629,6 +629,9 @@ JSONParser::decode_string(std::string const& str)
{
case '\\':
case '\"':
case '/':
// \/ is allowed in json input, but so is /, so we
// don't map / to \/ in output.
result.append(1, ch);
break;
case 'b':
@ -875,7 +878,7 @@ void JSONParser::getToken()
case ls_backslash:
/* cSpell: ignore bfnrt */
if (strchr("\\\"bfnrt", *p))
if (strchr("\\\"/bfnrt", *p))
{
lex_state = ls_string;
}

View File

@ -1,3 +1,3 @@
{"a": "bcd", "e": [1,
2, 3,4,"five", {"six": 7, "8": 9}, null, true,
false]}
false, "a\b\f\n\r\t\\\"\/z"]}

View File

@ -12,6 +12,7 @@
},
null,
true,
false
false,
"a\b\f\n\r\t\\\"/z"
]
}