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

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

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 5.5(EOL), 10.0(EOL), 10.1(EOL), 10.2(EOL)
    • 10.2.0
    • Character Sets
    • 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

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

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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