Skip to content

Commit

Permalink
MDEV-13138 JSON_OBJECT returns null with strings containing backticks.
Browse files Browse the repository at this point in the history
        Condition was fixed.
  • Loading branch information
Alexey Botchkov committed Sep 12, 2017
1 parent 66a09bd commit 594c6b3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions mysql-test/r/func_json.result
Original file line number Diff line number Diff line change
Expand Up @@ -674,3 +674,9 @@ 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
SELECT JSON_OBJECT('foo', '`');
JSON_OBJECT('foo', '`')
{"foo": "`"}
SELECT JSON_OBJECT("foo", "bar`bar");
JSON_OBJECT("foo", "bar`bar")
{"foo": "bar`bar"}
6 changes: 6 additions & 0 deletions mysql-test/t/func_json.test
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,9 @@ select JSON_EXTRACT('{\"input1\":\"\\u00f6\"}', '$.\"input1\"');
#
select JSON_EXTRACT('{"foo": "bar" foobar foo invalid ', '$.foo');

#
# MDEV-13138 JSON_OBJECT returns null with strings containing backticks.
#
SELECT JSON_OBJECT('foo', '`');
SELECT JSON_OBJECT("foo", "bar`bar");

2 changes: 1 addition & 1 deletion strings/json_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1586,7 +1586,7 @@ int json_escape(CHARSET_INFO *str_cs,
enum json_esc_char_classes c_class;

str+= c_len;
if (c_chr > 0x60 || (c_class= json_escape_chr_map[c_chr]) == ESC_)
if (c_chr >= 0x60 || (c_class= json_escape_chr_map[c_chr]) == ESC_)
{
if ((c_len= json_cs->cset->wc_mb(json_cs, c_chr, json, json_end)) > 0)
{
Expand Down

0 comments on commit 594c6b3

Please sign in to comment.