1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-19670 json escaped unicode parse error.

Fixed 4-byte length characters handled incorrectly.
This commit is contained in:
Alexey Botchkov
2019-09-12 11:12:55 +04:00
parent 0fa5ad3acf
commit 9554ef0678
3 changed files with 19 additions and 1 deletions

View File

@ -942,5 +942,14 @@ def json_depnth 3 10 1 N 32897 0 63
json_length json_depnth json_length json_depnth
2 3 2 3
# #
# MDEV-19670 json escaped unicode parse error
#
SELECT json_valid('{"value":"\\ud83d\\ude0a"}');
json_valid('{"value":"\\ud83d\\ude0a"}')
1
SELECT json_valid('{"test": "\\ud83d\\ude0b"}');
json_valid('{"test": "\\ud83d\\ude0b"}')
1
#
# End of 10.3 tests # End of 10.3 tests
# #

View File

@ -561,6 +561,13 @@ SELECT
--enable_ps_protocol --enable_ps_protocol
--disable_metadata --disable_metadata
--echo #
--echo # MDEV-19670 json escaped unicode parse error
--echo #
SELECT json_valid('{"value":"\\ud83d\\ude0a"}');
SELECT json_valid('{"test": "\\ud83d\\ude0b"}');
--echo # --echo #
--echo # End of 10.3 tests --echo # End of 10.3 tests
--echo # --echo #

View File

@ -320,15 +320,17 @@ static int json_handle_esc(json_string_t *s)
if (s->c_next != '\\') if (s->c_next != '\\')
return s->error= JE_SYN; return s->error= JE_SYN;
s->c_str+= c_len;
if ((c_len= json_next_char(s)) <= 0) if ((c_len= json_next_char(s)) <= 0)
return s->error= json_eos(s) ? JE_EOS : JE_BAD_CHR; return s->error= json_eos(s) ? JE_EOS : JE_BAD_CHR;
if (s->c_next != 'u') if (s->c_next != 'u')
return s->error= JE_SYN; return s->error= JE_SYN;
s->c_str+= c_len;
if (read_4_hexdigits(s, code+2)) if (read_4_hexdigits(s, code+2))
return 1; return 1;
if ((c_len= my_utf16_uni(0, &s->c_next, code, code+4)) == 2) if ((c_len= my_utf16_uni(0, &s->c_next, code, code+4)) == 4)
return 0; return 0;
} }
return s->error= JE_BAD_CHR; return s->error= JE_BAD_CHR;