Bug #70568 JSON_VALID treats invalid values as valid
Submitted: 9 Oct 2013 18:42 Modified: 30 Oct 2013 22:15
Reporter: Sveta Smirnova Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: JSON User-defined function ( UDF ) Severity:S3 (Non-critical)
Version:0.2 OS:Any
Assigned to:
Triage: Needs Triage: D2 (Serious)

[9 Oct 2013 18:42] Sveta Smirnova
Description:
JSON_VALID treats some invalid values as valid

How to repeat:
mysql> select json_valid('{"a":false,}');
+----------------------------+
| json_valid('{"a":false,}') |
+----------------------------+
|                          1 |
+----------------------------+
1 row in set (0.00 sec)

mysql> select json_valid('{"a":"\z"}');
+--------------------------+
| json_valid('{"a":"\z"}') |
+--------------------------+
|                        1 |
+--------------------------+
1 row in set (0.00 sec)
[9 Oct 2013 18:44] Sveta Smirnova
Posted by developer:
 
\z should be interpreted as special symbol, but it is not.
[30 Oct 2013 22:14] Sveta Smirnova
Posted by developer:
 
Fixed in versions 0.2.1 and 0.3.0

select json_valid('{"a":"\z"}'); is documentation issue: "UDFs get escaped strings, therefore you need to double-escape symbol "\" to let JSON parser to deal with it. See bug70568.test and json_valid.test for usage examples." README file was also updated.
[30 Oct 2013 22:39] Sveta Smirnova
Case for select json_valid('{"a":"\\z"}'); fixed.