diff options
-rw-r--r-- | src/xml/dom/qdom.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qdom/tst_qdom.cpp | 24 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index fc3df05..85b89de 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -7557,6 +7557,8 @@ bool QDomHandler::externalEntityDecl(const QString &name, const QString &publicI bool QDomHandler::notationDecl(const QString & name, const QString & publicId, const QString & systemId) { QDomNotationPrivate* n = new QDomNotationPrivate(doc, 0, name, publicId, systemId); + // keep the refcount balanced: appendChild() does a ref anyway. + n->ref.deref(); doc->doctype()->appendChild(n); return true; } diff --git a/tests/auto/qdom/tst_qdom.cpp b/tests/auto/qdom/tst_qdom.cpp index 32eff9d..3ba75e3 100644 --- a/tests/auto/qdom/tst_qdom.cpp +++ b/tests/auto/qdom/tst_qdom.cpp @@ -132,6 +132,7 @@ private slots: void taskQTBUG4595_dontAssertWhenDocumentSpecifiesUnknownEncoding() const; void cloneDTD_QTBUG8398() const; + void DTDNotationDecl(); void cleanupTestCase() const; @@ -1930,5 +1931,28 @@ void tst_QDom::cloneDTD_QTBUG8398() const domDocument2.save(stream, 0); QCOMPARE(output, expected); } + +void tst_QDom::DTDNotationDecl() +{ + QString dtd("<?xml version='1.0' encoding='UTF-8'?>\n" + "<!DOCTYPE first [\n" + "<!NOTATION gif SYSTEM 'image/gif'>\n" + "<!NOTATION jpeg SYSTEM 'image/jpeg'>\n" + "]>\n" + "<first/>\n"); + + QDomDocument domDocument; + QVERIFY(domDocument.setContent(dtd)); + + const QDomDocumentType doctype = domDocument.doctype(); + QCOMPARE(doctype.notations().size(), 2); + + QVERIFY(doctype.namedItem(QString("gif")).isNotation()); + QCOMPARE(doctype.namedItem(QString("gif")).toNotation().systemId(), QString("image/gif")); + + QVERIFY(doctype.namedItem(QString("jpeg")).isNotation()); + QCOMPARE(doctype.namedItem(QString("jpeg")).toNotation().systemId(), QString("image/jpeg")); +} + QTEST_MAIN(tst_QDom) #include "tst_qdom.moc" |