Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-41677

JSON_SCHEMA_VALID counts JSON string encoding rather than decoded characters for maxLength and minLength

    XMLWordPrintable

Details

    • Bug
    • Status: In Review (View Workflow)
    • Critical
    • Resolution: Unresolved
    • 12.3.2
    • 11.4
    • JSON
    • 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('

      {"maxLength":1}

      ', '"
      u0061"') AS escaped_a;

      SET @e = CONVERT(0x22C3A922 USING utf8mb4); – JSON string containing U+00E9

      SELECT JSON_VALID(@e),
      JSON_SCHEMA_VALID('

      {"maxLength":1}

      ', @e) AS max_length_1,
      JSON_SCHEMA_VALID('

      {"minLength":2}

      ', @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.

      Attachments

        Activity

          People

            rucha174 Rucha Deodhar
            123 zhang hanshuo
            Rucha Deodhar Rucha Deodhar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.