QDom: preserve empty CDATA sections
Restores Qt 5 behavior. Fixes: QTBUG-101992 Pick-to: 6.3 6.2 Change-Id: I3b9fc077c0a0fd30f4fcce7bfa342dbe96b2c582 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
parent
64db79f856
commit
edb64351cd
@ -364,7 +364,7 @@ bool QDomParser::parseBody()
|
||||
break;
|
||||
case QXmlStreamReader::Characters:
|
||||
if (!reader->isWhitespace()) { // Skip the content consisting of only whitespaces
|
||||
if (!reader->text().trimmed().isEmpty()) {
|
||||
if (reader->isCDATA() || !reader->text().trimmed().isEmpty()) {
|
||||
if (!domBuilder.characters(reader->text().toString(), reader->isCDATA())) {
|
||||
domBuilder.fatalError(QDomParser::tr(
|
||||
"Error occurred while processing the element content"));
|
||||
|
@ -87,6 +87,7 @@ private slots:
|
||||
void invalidCharData();
|
||||
|
||||
void roundTripAttributes() const;
|
||||
void roundTripCDATA() const;
|
||||
void normalizeEndOfLine() const;
|
||||
void normalizeAttributes() const;
|
||||
void serializeWeirdEOL() const;
|
||||
@ -1441,6 +1442,17 @@ void tst_QDom::roundTripAttributes() const
|
||||
QCOMPARE(QString::fromLatin1(serialized.constData()), QString::fromLatin1(expected.constData()));
|
||||
}
|
||||
|
||||
void tst_QDom::roundTripCDATA() const
|
||||
{
|
||||
const QString input = u"<?xml version='1.0' encoding='UTF-8'?>\n"
|
||||
"<content><![CDATA[]]></content>\n"_qs;
|
||||
QString errorMsg;
|
||||
QDomDocument doc;
|
||||
QVERIFY(doc.setContent(input, false, &errorMsg));
|
||||
QVERIFY(errorMsg.isEmpty());
|
||||
QCOMPARE(doc.toString(), input);
|
||||
}
|
||||
|
||||
void tst_QDom::normalizeEndOfLine() const
|
||||
{
|
||||
QByteArray input("<a>\r\nc\rc\ra\na</a>");
|
||||
|
Loading…
Reference in New Issue
Block a user