From c3b959733a739e9b2fc00b2af469fa44f3048e29 Mon Sep 17 00:00:00 2001 From: Ye ShanShan Date: Fri, 10 Jun 2022 13:53:40 +0800 Subject: Add QDom internalSubset implementation QDom's internalSubset() always returned empty because nothing actually set the internal data member it returns. When parsing the DECLTYPE, extract the internal subset and save it to the doctype()'s member when present. Pick-to: 5.15 6.2 6.3 6.4 Fixes: QTBUG-53661 Change-Id: I6e41ff8b914381168246073b3289d82205b1c255 Reviewed-by: Sona Kurazyan --- tests/auto/xml/dom/qdom/tst_qdom.cpp | 66 ++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'tests') diff --git a/tests/auto/xml/dom/qdom/tst_qdom.cpp b/tests/auto/xml/dom/qdom/tst_qdom.cpp index f05020f61c..0736e158fc 100644 --- a/tests/auto/xml/dom/qdom/tst_qdom.cpp +++ b/tests/auto/xml/dom/qdom/tst_qdom.cpp @@ -97,6 +97,8 @@ private slots: void cloneDTD_QTBUG8398() const; void DTDNotationDecl(); void DTDEntityDecl(); + void DTDInternalSubset() const; + void DTDInternalSubset_data() const; void QTBUG49113_dontCrashWithNegativeIndex() const; void cleanupTestCase() const; @@ -2044,5 +2046,69 @@ void tst_QDom::QTBUG49113_dontCrashWithNegativeIndex() const QVERIFY(node.isNull()); } +void tst_QDom::DTDInternalSubset() const +{ + QFETCH( QString, doc ); + QFETCH( QString, internalSubset ); + QXmlStreamReader reader(doc); + QDomDocument document; + QVERIFY(document.setContent(&reader, true)); + + QCOMPARE(document.doctype().internalSubset(), internalSubset); +} + +void tst_QDom::DTDInternalSubset_data() const +{ + QTest::addColumn("doc"); + QTest::addColumn("internalSubset"); + + QTest::newRow("data1") << "\n" + "\n" + "\n" + << "" ; + + QTest::newRow("data2") << "\n" + "\n" + "\n" + << "" ; + + const QString internalSubset0( + "\n" + "\n" + ); + QTest::newRow("data3") << "\n" + "\n" + "\n" + << internalSubset0; + + const QString internalSubset1( + "\n" + "\n" + ); + QTest::newRow("data4") << "\n" + "\n" + "\n" + << internalSubset1; + + QTest::newRow("data5") << "\n" + "\n" + "\n" + << internalSubset0; + + QTest::newRow("data6") << "\n" + "\n" + "\n" + << internalSubset0; +} + QTEST_MAIN(tst_QDom) #include "tst_qdom.moc" -- cgit v1.2.3