Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
6.3.0 Beta3
-
edb64351cd (qt/qtbase/dev) 67baa15458 (qt/qtbase/6.3) 8b369de926 (qt/qtbase/6.2) 8b369de926 (qt/tqtc-qtbase/6.2) 67baa15458 (qt/tqtc-qtbase/6.3) edb64351cd (qt/tqtc-qtbase/dev)
Description
If an XML document contains "<![CDATA[]]>", then the corresponding QDomCDATASection node is not created in Qt 6. Qt 5 does not have this issue.
There are some documented behaviour changes due to replacing the parser with QXmlStreamReader: https://doc.qt.io/qt-6/xml-changes-qt6.html#qdom-and-qdomdocument However, this does not explain the new behaviour of QDomDocument because QXmlStreamReader does output the empty CDATA section.
Furthermore, QDomDocument::createCDATASection can produce such an empty section.
Example
QString xmlData = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" "<content><![CDATA[]]></content>"; QDomDocument doc; doc.setContent(xmlData, false); qDebug("RAW:"); qDebug() << doc.toString(); doc.elementsByTagName("content").at(0).appendChild( doc.createCDATASection("") ); qDebug("APPENDED:"); qDebug() << doc.toString();
Qt 5 output (correct)
RAW: "<?xml version='1.0' encoding='UTF-8'?>\n<content><![CDATA[]]></content>\n" APPENDED: "<?xml version='1.0' encoding='UTF-8'?>\n<content><![CDATA[]]><![CDATA[]]></content>\n"
Qt 6 output (wrong)
RAW: "<?xml version='1.0' encoding='UTF-8'?>\n<content/>\n" APPENDED: "<?xml version='1.0' encoding='UTF-8'?>\n<content><![CDATA[]]></content>\n"