From d1fabb49a37d728e5f22dab075d119f32fc20f4f Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Mon, 22 Sep 2014 14:02:56 +0200 Subject: 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 Reviewed-by: Thiago Macieira Reviewed-by: Richard J. Moore --- src/xml/sax/qxml.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/xml/sax') diff --git a/src/xml/sax/qxml.cpp b/src/xml/sax/qxml.cpp index 50900c17f0..0c5855cf07 100644 --- a/src/xml/sax/qxml.cpp +++ b/src/xml/sax/qxml.cpp @@ -5265,7 +5265,12 @@ bool QXmlSimpleReaderPrivate::parsePEReference() return false; } if (ret) { - xmlRefString = ret->data(); + QString buffer = ret->data(); + while (!buffer.isEmpty()) { + xmlRefString += buffer; + ret->fetchData(); + buffer = ret->data(); + } delete ret; if (!stripTextDecl(xmlRefString)) { reportParseError(QLatin1String(XMLERR_ERRORINTEXTDECL)); @@ -7614,7 +7619,14 @@ bool QXmlSimpleReaderPrivate::processReference() return false; } if (ret) { - QString xmlRefString = ret->data(); + QString xmlRefString; + QString buffer = ret->data(); + while (!buffer.isEmpty()) { + xmlRefString += buffer; + ret->fetchData(); + buffer = ret->data(); + } + delete ret; if (!stripTextDecl(xmlRefString)) { reportParseError(QLatin1String(XMLERR_ERRORINTEXTDECL)); -- cgit v1.2.3