Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-14395

QXmlStreamReader not able to process XML string/file with UTF-8 Byte Order Mark (BOM)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 4.7.1, 5.6.2
    • None
    • I believe this has shown up in Qt 4.7. We did not run into this with earlier versions of Qt, but we could have just been lucky.
    • 21

    Description

      I'm sure this can be argued, but I would expect BOM a common thing with XML and would expect the Qt's XML processing to handle it.

      Small Qt App to show the difference in behavior. Attached in xmlBom.zip.

      C:\Users\jwild\Dev\Qt\xmlBom\xmlBom.zip

      Only 1st string without BOM has it's elements listed. Here is the main
      code of the test.

      void MainWindow::list()
      {
          QString s = "Hello World";
          QString xmlWithoutBom = "<body><element>Hello</element></body>";
          QString xmlWithBom = "\xef\xbb\xbf<body><element>Hello</element></body>";
      
          QXmlStreamReader xmlReader;
      
          s = "Parse without BOM: \n";
          xmlReader.addData(xmlWithoutBom);
          while (!xmlReader.atEnd()) {
              if (xmlReader.isStartElement()) {
                  s += "Start Elem: " + xmlReader.name().toString() + "\n";
              }
              xmlReader.readNext();
          }
          s += "End Parse without BOM\n\n";
      
      
          s += "Parse with BOM: \n";
          xmlReader.addData(xmlWithBom);
          while (!xmlReader.atEnd()) {
              if (xmlReader.isStartElement()) {
                  s += "Start Elem: " + xmlReader.name().toString() + "\n";
              }
              xmlReader.readNext();
          }
          s += "End Parse with BOM\n\n";
      
          textViewer->setPlainText( s ); 
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            cnn Qt Core & Network
            joseph.wild@nokia.com Joseph Wild
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes