diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-01-15 20:53:21 +0100 |
---|---|---|
committer | Robert Loehning <robert.loehning@qt.io> | 2020-02-10 14:15:19 +0100 |
commit | 4b71f1c590bb379f866f89a375431bc378bac8e3 (patch) | |
tree | 0ccb7b1b86dbd84f8562f8b7696c1b256c9b8533 /src | |
parent | 52c0c4efccee5388b64ead635c7c973713e75318 (diff) |
QXmlStreamReader: early return in case of malformed attributes
There's no point at keep raising errors after encountering the
first malformed attribute.
(cherry picked from commit 4d8a515a230ca9864a94830fd376a1d3ecbe6886)
Change-Id: I1c5e8caf92b09c91ec8c37eb72c72f2f937013e6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/serialization/qxmlstream.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/corelib/serialization/qxmlstream.cpp b/src/corelib/serialization/qxmlstream.cpp index 827996ee2d..ddd331c12a 100644 --- a/src/corelib/serialization/qxmlstream.cpp +++ b/src/corelib/serialization/qxmlstream.cpp @@ -50,6 +50,7 @@ #endif #include <qstack.h> #include <qbuffer.h> +#include <qscopeguard.h> #ifndef QT_BOOTSTRAPPED #include <qcoreapplication.h> #else @@ -1582,6 +1583,7 @@ QStringRef QXmlStreamReaderPrivate::namespaceForPrefix(const QStringRef &prefix) */ void QXmlStreamReaderPrivate::resolveTag() { + const auto attributeStackCleaner = qScopeGuard([this](){ attributeStack.clear(); }); int n = attributeStack.size(); if (namespaceProcessing) { @@ -1649,7 +1651,10 @@ void QXmlStreamReaderPrivate::resolveTag() if (attributes[j].name() == attribute.name() && attributes[j].namespaceUri() == attribute.namespaceUri() && (namespaceProcessing || attributes[j].qualifiedName() == attribute.qualifiedName())) + { raiseWellFormedError(QXmlStream::tr("Attribute '%1' redefined.").arg(attribute.qualifiedName())); + return; + } } } @@ -1680,8 +1685,6 @@ void QXmlStreamReaderPrivate::resolveTag() attribute.m_isDefault = true; attributes.append(attribute); } - - attributeStack.clear(); } void QXmlStreamReaderPrivate::resolvePublicNamespaces() |