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

LOAD XML INFILE does not handle well broken multi-byte characters

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.5, 10.0, 10.1, 10.2
    • Fix Version/s: 10.2.0
    • Component/s: Character Sets
    • Labels:
      None

      Description

      I create an XML file with a broken utf8 byte sequence:

      printf "<table><row><a>a\xD0</a></row></table>" >/tmp/test.xml
      

      Notice, 0xD0 is a utf8 leading byte of a 2-byte character, but it is not followed by a tail byte.

      Now I try to load this file into a table:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a TEXT CHARACTER SET utf8);
      LOAD XML INFILE '/tmp/test.xml' INTO TABLE t1 CHARACTER SET utf8 ROWS IDENTIFIED BY '<row>';
      SHOW WARNINGS;
      SELECT * FROM t1;
      

      It produces this warning:

      +---------+------+------------------------------------------------------------+
      | Level   | Code | Message                                                    |
      +---------+------+------------------------------------------------------------+
      | Warning | 1366 | Incorrect string value: '\xD0</a>' for column 'a' at row 1 |
      +---------+------+------------------------------------------------------------+
      

      and this result set:

      +--------+
      | a      |
      +--------+
      | a?</a> |
      +--------+
      

      This is wrong. The closing tag '</a>' was interpreted as data rather than markup.
      The expected result would be to return 'a?' rather than 'a?</a>'.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                bar Alexander Barkov
                Reporter:
                bar Alexander Barkov
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: