summaryrefslogtreecommitdiffstats
path: root/src/xml
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2022-06-17 14:43:17 +0200
committerMarc Mutz <marc.mutz@qt.io>2022-06-20 21:29:04 +0000
commitda0d7f61c851431d14430684c62345bc23dbf001 (patch)
tree3e7bf228e48edc2ef9972806b46c83be78a585fa /src/xml
parent3d73aa660b5e1af5758ae7207ce1c05d7a0458e1 (diff)
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 <marc.mutz@qt.io>
Diffstat (limited to 'src/xml')
-rw-r--r--src/xml/dom/qdom.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp
index 486894019c..e0e9a465ef 100644
--- a/src/xml/dom/qdom.cpp
+++ b/src/xml/dom/qdom.cpp
@@ -22,7 +22,7 @@
#include <qdebug.h>
#include <qxmlstream.h>
#include <private/qduplicatetracker_p.h>
-
+#include <private/qstringiterator_p.h>
#include <stdio.h>
#include <limits>
@@ -156,10 +156,11 @@ static QString fixedCharData(const QString &data, bool *ok)
}
QString result;
- for (int i = 0; i < data.size(); ++i) {
- QChar c = data.at(i);
+ QStringIterator it(data);
+ while (it.hasNext()) {
+ const char32_t c = it.next(QChar::Null);
if (QXmlUtils::isChar(c)) {
- result.append(c);
+ result.append(QChar::fromUcs4(c));
} else if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
*ok = false;
return QString();