From da0d7f61c851431d14430684c62345bc23dbf001 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Fri, 17 Jun 2022 14:43:17 +0200 Subject: QDom: Stop treating non-BMP characters as invalid According to https://www.w3.org/TR/REC-xml/#NT-Char unicode characters within the range of [#x10000-#x10FFFF] are considered to be valid, so fix the check for valid characters accordingly. This requires changing the loop over the input QString to iterate over code points (instead of code units). Fixes: QTBUG-104362 Pick-to: 6.4 6.3 6.2 5.15 Change-Id: I7dcf5cad05265a54882807a50522d28b647e06ee Reviewed-by: Marc Mutz --- tests/auto/xml/dom/qdom/tst_qdom.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 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 e1c2b12ab5..f05020f61c 100644 --- a/tests/auto/xml/dom/qdom/tst_qdom.cpp +++ b/tests/auto/xml/dom/qdom/tst_qdom.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -62,6 +63,7 @@ private slots: void invalidQualifiedName(); void invalidCharData_data(); void invalidCharData(); + void nonBMPCharacters(); void roundTripAttributes() const; void roundTripCDATA() const; @@ -1342,6 +1344,10 @@ void tst_QDom::invalidCharData_data() QTest::newRow( "fSupplementary Plane: 𝄞 😂 🀄 🀶 🃪 🃋"_qs; + + QString errorMsg; + QDomDocument doc; + doc.setContent(input, &errorMsg); + QVERIFY(errorMsg.isEmpty()); + QCOMPARE(doc.toString(-1), input); +} + void tst_QDom::roundTripAttributes() const { /* Create an attribute via the QDom API with weird whitespace content. */ -- cgit v1.2.3