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

tst_QDom relies on specific QHash ordering

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 4.8.x, 5.0.0
    • XML: DOM
    • None
    • 9e75a4cca (dev)

    Description

      tst_QDom::cloneDTD_QTBUG8398() is relying on a specific QHash ordering. It's even commented in the source:

          QString dtd("<?xml version='1.0' encoding='UTF-8'?>\n"
                         "<!DOCTYPE first [\n"
                         "<!ENTITY secondFile SYSTEM 'second.xml'>\n"
                         "<!ENTITY thirdFile SYSTEM 'third.xml'>\n"
                         "]>\n"
                         "<first/>\n");
          QDomDocument domDocument;
          QVERIFY(domDocument.setContent(dtd));
          QDomDocument domDocument2 = domDocument.cloneNode(true).toDocument();
      
          // for some reason, our DOM implementation reverts the order of entities
          QString expected("<?xml version='1.0' encoding='UTF-8'?>\n"
                         "<!DOCTYPE first [\n"
                         "<!ENTITY thirdFile SYSTEM 'third.xml'>\n"
                         "<!ENTITY secondFile SYSTEM 'second.xml'>\n"
                         "]>\n"
                         "<first/>\n");
          QString output;
          QTextStream stream(&output);
          domDocument2.save(stream, 0);
          QCOMPARE(output, expected);
      

      The swap happens because of the QHash usage. Changing QHash / qHash causes the test to fail.

      I don't know if QHash usage inside QDom is legitimate (i.e. the ENTITY declarations may appear in any order), or it's just a wrong test.

      Attachments

        Issue Links

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

          Activity

            People

              Unassigned Unassigned
              peppe Giuseppe D'Angelo
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes