QXmlSimpleReader shall handle external entity reference file over 1k

This commit fixes a bug that causes QXmlSimpleReader to handle only
external reference files less than 1k. Instead of reading the
first 1k of the reference file, it reads all data from the file into
memory. The change is not optimal for memory management, but there does
not seem to be better solution without breaking the existing API.

A similar but incomplete patch was already applied to Qt 4.7 but never
made it into Qt 5. This patch is based on a Qt 4.7 patch and adds the
missing cases.

Task-number: QTBUG-26910
Change-Id: Ia4d055ded80a40ce76b79fc61ad585e8ebb719db
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Richard J. Moore <rich@kde.org>
This commit is contained in:
Alex Blasche 2014-09-22 14:02:56 +02:00
parent c96426f19f
commit d1fabb49a3

View File

@ -5265,7 +5265,12 @@ bool QXmlSimpleReaderPrivate::parsePEReference()
return false; return false;
} }
if (ret) { if (ret) {
xmlRefString = ret->data(); QString buffer = ret->data();
while (!buffer.isEmpty()) {
xmlRefString += buffer;
ret->fetchData();
buffer = ret->data();
}
delete ret; delete ret;
if (!stripTextDecl(xmlRefString)) { if (!stripTextDecl(xmlRefString)) {
reportParseError(QLatin1String(XMLERR_ERRORINTEXTDECL)); reportParseError(QLatin1String(XMLERR_ERRORINTEXTDECL));
@ -7614,7 +7619,14 @@ bool QXmlSimpleReaderPrivate::processReference()
return false; return false;
} }
if (ret) { if (ret) {
QString xmlRefString = ret->data(); QString xmlRefString;
QString buffer = ret->data();
while (!buffer.isEmpty()) {
xmlRefString += buffer;
ret->fetchData();
buffer = ret->data();
}
delete ret; delete ret;
if (!stripTextDecl(xmlRefString)) { if (!stripTextDecl(xmlRefString)) {
reportParseError(QLatin1String(XMLERR_ERRORINTEXTDECL)); reportParseError(QLatin1String(XMLERR_ERRORINTEXTDECL));