Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
4.7.1
-
None
-
Win7, MSVC++ 2010 EE
Description
QDom* saving mechanism doesn't escape '(apostrophe) and >(greater) characters when perform saving an XML tree into a document by calling toString() method.
Obviously it is a bug in the escaping procedure.
Code for reproducing:
#include <QDomElement> #include <QDomText> #include <QDomDocument> #include <QCoreApplication> #include <QtDebug> int main(int argc, char** argv) { QCoreApplication App(argc, argv); QDomDocument XMLContent; XMLContent.appendChild(XMLContent.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"utf-8\"")); QDomElement NewNode = XMLContent.createElement("element"); NewNode.setAttribute("attribute", "<>&'\""); QDomText NewText = XMLContent.createTextNode("<>&'\""); NewNode.appendChild(NewText); XMLContent.appendChild(NewNode); qDebug() << XMLContent.toString(); return App.exec(); }
It displays:
"<?xml version="1.0" encoding="utf-8"?> <element attribute="<>&'""><>&'"</element> "
but it should display:
"<?xml version="1.0" encoding="utf-8"?> <element attribute="<>&'""><>&'"</element> "
Here is the responsible procedure:
static QString encodeText(const QString &str, QTextStream &s, const bool encodeQuotes = true, const bool performAVN = false, const bool encodeEOLs = false) {