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

COLUMN_JSON() doesn't escape control characters in string values

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 10.0.15
    • Fix Version/s: None
    • Component/s: Dynamic Columns
    • Labels:
      None
    • Environment:
      Darwin 13.4.0 Darwin Kernel Version 13.4.0: Sun Aug 17 19:50:11 PDT 2014; root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64

      Description

      According to RFC 4627 http://www.ietf.org/rfc/rfc4627.txt

      "All Unicode characters may be placed within the quotation marks except for the characters that must be escaped: quotation mark, reverse solidus, and the control characters (U+0000 through U+001F)."

      If you store a string that contains a control character in a dynamic column and fetch it back with COLUMN_JSON() then the control character is not escaped in the JSON encoded value returned.

      All the JSON decoders I have tried it with fail on such strings.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            thefsb Tom added a comment -

            There is a related question.

            Dynamic columns allow BINARY values. JSON cannot in general represent binary data. At present, if a dynamic column has a BINARY value then COLUMN_JSON just puts it in quotation marks and sends it. If the document is utf8 then this usually means that the document returned is not valid JSON. Most JSON encoders reject inputs that cannot be encoded with an error but Maria instead returns an invalid document that cannot be decoded using normal JSON libraries.

            However, I don't know what the right behavior should be.

            Show
            thefsb Tom added a comment - There is a related question. Dynamic columns allow BINARY values. JSON cannot in general represent binary data. At present, if a dynamic column has a BINARY value then COLUMN_JSON just puts it in quotation marks and sends it. If the document is utf8 then this usually means that the document returned is not valid JSON. Most JSON encoders reject inputs that cannot be encoded with an error but Maria instead returns an invalid document that cannot be decoded using normal JSON libraries. However, I don't know what the right behavior should be.

              People

              • Assignee:
                sanja Oleksandr Byelkin
                Reporter:
                thefsb Tom
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: