Skip to content

Commit

Permalink
MDEV-19628 JSON with starting double quotes key is not valid.
Browse files Browse the repository at this point in the history
First character of the key name is just skipped, so the escapement
wasn't handled properly.
  • Loading branch information
Alexey Botchkov committed Sep 30, 2019
1 parent 2911a9a commit 6ac2a35
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
12 changes: 12 additions & 0 deletions mysql-test/main/func_json.result
Original file line number Diff line number Diff line change
Expand Up @@ -951,5 +951,17 @@ SELECT json_valid('{"test": "\\ud83d\\ude0b"}');
json_valid('{"test": "\\ud83d\\ude0b"}')
1
#
# MDEV-19670 json escaped unicode parse error
#
SELECT JSON_VALID('{"admin\\"": null}'), '{"admin\\"": null}'
UNION
SELECT JSON_VALID('{"\\"admin": null}'), '{"\\"admin": null}'
UNION
SELECT JSON_VALID('{"\\"": null}'), '{"\\"": null}';
JSON_VALID('{"admin\\"": null}') {"admin\"": null}
1 {"admin\"": null}
1 {"\"admin": null}
1 {"\"": null}
#
# End of 10.3 tests
#
10 changes: 10 additions & 0 deletions mysql-test/main/func_json.test
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,16 @@ SELECT
SELECT json_valid('{"value":"\\ud83d\\ude0a"}');
SELECT json_valid('{"test": "\\ud83d\\ude0b"}');

--echo #
--echo # MDEV-19670 json escaped unicode parse error
--echo #

SELECT JSON_VALID('{"admin\\"": null}'), '{"admin\\"": null}'
UNION
SELECT JSON_VALID('{"\\"admin": null}'), '{"\\"admin": null}'
UNION
SELECT JSON_VALID('{"\\"": null}'), '{"\\"": null}';

--echo #
--echo # End of 10.3 tests
--echo #
2 changes: 1 addition & 1 deletion mysql-test/suite/json/r/json_no_table.result

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions strings/json_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,8 @@ static int skip_colon(json_engine_t *j)
static int skip_key(json_engine_t *j)
{
int t_next, c_len;

j->s.c_str-= j->sav_c_len;
while (json_read_keyname_chr(j) == 0) {}

if (j->s.error)
Expand Down

0 comments on commit 6ac2a35

Please sign in to comment.