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>
This commit is contained in:
Giuseppe D'Angelo 2020-01-15 20:53:21 +01:00 committed by Robert Loehning
parent 52c0c4efcc
commit 4b71f1c590
3 changed files with 9010 additions and 2 deletions

View File

@ -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()

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff