mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-12982 JSON_EXTRACT returns data for invalid JSON.
Let's check the validity to the end of the JSON.
This commit is contained in:
@ -669,3 +669,8 @@ JSON_EXTRACT('{\"asdf\":true}', "$.\"asdf\"") = 1
|
|||||||
select JSON_EXTRACT('{\"input1\":\"\\u00f6\"}', '$.\"input1\"');
|
select JSON_EXTRACT('{\"input1\":\"\\u00f6\"}', '$.\"input1\"');
|
||||||
JSON_EXTRACT('{\"input1\":\"\\u00f6\"}', '$.\"input1\"')
|
JSON_EXTRACT('{\"input1\":\"\\u00f6\"}', '$.\"input1\"')
|
||||||
"\u00f6"
|
"\u00f6"
|
||||||
|
select JSON_EXTRACT('{"foo": "bar" foobar foo invalid ', '$.foo');
|
||||||
|
JSON_EXTRACT('{"foo": "bar" foobar foo invalid ', '$.foo')
|
||||||
|
NULL
|
||||||
|
Warnings:
|
||||||
|
Warning 4038 Syntax error in JSON text in argument 1 to function 'json_extract' at position 15
|
||||||
|
@ -317,3 +317,8 @@ select JSON_EXTRACT('{\"asdf\":true}', "$.\"asdf\"") = false;
|
|||||||
select JSON_EXTRACT('{\"asdf\":true}', "$.\"asdf\"") = 1;
|
select JSON_EXTRACT('{\"asdf\":true}', "$.\"asdf\"") = 1;
|
||||||
select JSON_EXTRACT('{\"input1\":\"\\u00f6\"}', '$.\"input1\"');
|
select JSON_EXTRACT('{\"input1\":\"\\u00f6\"}', '$.\"input1\"');
|
||||||
|
|
||||||
|
#
|
||||||
|
# MDEV-129892 JSON_EXTRACT returns data for invalid JSON
|
||||||
|
#
|
||||||
|
select JSON_EXTRACT('{"foo": "bar" foobar foo invalid ', '$.foo');
|
||||||
|
|
||||||
|
@ -821,7 +821,11 @@ String *Item_func_json_extract::read_json(String *str,
|
|||||||
not_first_value= 1;
|
not_first_value= 1;
|
||||||
|
|
||||||
if (!possible_multiple_values)
|
if (!possible_multiple_values)
|
||||||
|
{
|
||||||
|
/* Loop to the end of the JSON just to make sure it's valid. */
|
||||||
|
while (json_get_path_next(&je, &p) == 0) {}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (je.s.error)
|
if (je.s.error)
|
||||||
|
Reference in New Issue
Block a user