summaryrefslogtreecommitdiffstats
path: root/src/xml
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-09-22 14:02:56 +0200
committerAlex Blasche <alexander.blasche@digia.com>2014-09-24 09:54:38 +0200
commitd1fabb49a37d728e5f22dab075d119f32fc20f4f (patch)
treef321bb7387e2b19cd16732525a2423934e6d73ab /src/xml
parentc96426f19f8c244c0f5748f0009016f576db9616 (diff)
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>
Diffstat (limited to 'src/xml')
-rw-r--r--src/xml/sax/qxml.cpp16
1 files changed, 14 insertions, 2 deletions
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));