Commit 36794a60cf2a9739d4e1b021c9ba00feef9d42da
1 parent
e7ecc348
Allow \/ in a json string
Showing
4 changed files
with
12 additions
and
3 deletions
ChangeLog
| 1 | +2022-02-25 Jay Berkenbilt <ejb@ql.org> | ||
| 2 | + | ||
| 3 | + * Bug fix in JSON parser: accept \/ in a string as valid input per | ||
| 4 | + JSON spec even though we don't translate / to \/ on output. | ||
| 5 | + | ||
| 1 | 2022-02-22 Jay Berkenbilt <ejb@ql.org> | 6 | 2022-02-22 Jay Berkenbilt <ejb@ql.org> |
| 2 | 7 | ||
| 3 | * Recognize PDF strings explicitly marked as UTF-8 as allowed by | 8 | * Recognize PDF strings explicitly marked as UTF-8 as allowed by |
libqpdf/JSON.cc
| @@ -629,6 +629,9 @@ JSONParser::decode_string(std::string const& str) | @@ -629,6 +629,9 @@ JSONParser::decode_string(std::string const& str) | ||
| 629 | { | 629 | { |
| 630 | case '\\': | 630 | case '\\': |
| 631 | case '\"': | 631 | case '\"': |
| 632 | + case '/': | ||
| 633 | + // \/ is allowed in json input, but so is /, so we | ||
| 634 | + // don't map / to \/ in output. | ||
| 632 | result.append(1, ch); | 635 | result.append(1, ch); |
| 633 | break; | 636 | break; |
| 634 | case 'b': | 637 | case 'b': |
| @@ -875,7 +878,7 @@ void JSONParser::getToken() | @@ -875,7 +878,7 @@ void JSONParser::getToken() | ||
| 875 | 878 | ||
| 876 | case ls_backslash: | 879 | case ls_backslash: |
| 877 | /* cSpell: ignore bfnrt */ | 880 | /* cSpell: ignore bfnrt */ |
| 878 | - if (strchr("\\\"bfnrt", *p)) | 881 | + if (strchr("\\\"/bfnrt", *p)) |
| 879 | { | 882 | { |
| 880 | lex_state = ls_string; | 883 | lex_state = ls_string; |
| 881 | } | 884 | } |
libtests/qtest/json_parse/good-01.json