Details
-
Bug
-
Status: In Review (View Workflow)
-
Critical
-
Resolution: Unresolved
-
12.3.2
-
MariaDB Server 12.3.2, Windows x64
-
JSON_SCHEMA_VALID counts JSON string encoding rather than decoded characters for maxLength and minLength
Description
Description
Two valid JSON documents, "a" and "\u0061", represent the same string. Under maxLength:1, MariaDB accepts the literal form but rejects the escaped form. Non-ASCII examples also behave as though encoded bytes, rather than decoded characters, determine the length.
Reproduce
SELECT JSON_VALID('"a"'), JSON_VALID('"
u0061"');
SELECT JSON_SCHEMA_VALID('
{"maxLength":1}', '"a"') AS literal_a,
JSON_SCHEMA_VALID('
', '"
u0061"') AS escaped_a;
SET @e = CONVERT(0x22C3A922 USING utf8mb4); – JSON string containing U+00E9
SELECT JSON_VALID(@e),
JSON_SCHEMA_VALID('
', @e) AS max_length_1,
JSON_SCHEMA_VALID('
', @e) AS min_length_2;
Result
MariaDB returns 1, 0 for the two equivalent a strings. For U+00E9, it returns 0 for maxLength:1 and 1 for minLength:2.
But excepted result.The equivalent a strings should both pass maxLength:1. U+00E9 is one character, so it should pass maxLength:1 and fail minLength:2. The JSON Schema specification defines string length by characters as defined by RFC 8259, not by the original JSON spelling.