summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Botchkov <holyfoot@askmonty.org>2017-09-12 13:26:03 +0400
committerAlexey Botchkov <holyfoot@askmonty.org>2017-09-12 13:26:03 +0400
commit594c6b37f3dacf537e804c7a9264eeb4d84b5671 (patch)
treeac73a571d1e2f398cbfe7dc00f17a36241a6beec
parent66a09bd6aba0f7b74492d198146bb8d47cdd9dbb (diff)
downloadmariadb-git-594c6b37f3dacf537e804c7a9264eeb4d84b5671.tar.gz
MDEV-13138 JSON_OBJECT returns null with strings containing backticks.
Condition was fixed.
-rw-r--r--mysql-test/r/func_json.result6
-rw-r--r--mysql-test/t/func_json.test6
-rw-r--r--strings/json_lib.c2
3 files changed, 13 insertions, 1 deletions
diff --git a/mysql-test/r/func_json.result b/mysql-test/r/func_json.result
index f89c5f1c71b..d11c0273024 100644
--- a/mysql-test/r/func_json.result
+++ b/mysql-test/r/func_json.result
@@ -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"}
diff --git a/mysql-test/t/func_json.test b/mysql-test/t/func_json.test
index eba492b72e8..3b978c1a1cf 100644
--- a/mysql-test/t/func_json.test
+++ b/mysql-test/t/func_json.test
@@ -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");
+
diff --git a/strings/json_lib.c b/strings/json_lib.c
index b0c843caec1..25e5e81e6f9 100644
--- a/strings/json_lib.c
+++ b/strings/json_lib.c
@@ -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)
{