From e8b49d0e33ea6c8a2814fcad70015dbcc28e9a5d Mon Sep 17 00:00:00 2001 From: Honglei Zhang Date: Fri, 19 Aug 2011 11:22:38 +0300 Subject: QXmlSimpleReader handle external entity reference file over 1k This commit fixes the bug that causes the QXmlSimpleReader can only handle external reference file less than 1k. Instead of reading the 1k buffer, the system will try to read all data from file into memory. This is not good for memory management. But there doesn't seem to be better solution without breaking the existing API. Task-number: QTBUG-21025 Reviewed-by: Peter Hartmann --- src/xml/sax/qxml.cpp | 8 +++++++- tests/auto/qxmlsimplereader/xmldocs/valid/ext-sa/015.ent | Bin 0 -> 2130 bytes tests/auto/qxmlsimplereader/xmldocs/valid/ext-sa/015.xml | 6 ++++++ .../qxmlsimplereader/xmldocs/valid/ext-sa/015.xml.ref | 10 ++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100755 tests/auto/qxmlsimplereader/xmldocs/valid/ext-sa/015.ent create mode 100644 tests/auto/qxmlsimplereader/xmldocs/valid/ext-sa/015.xml create mode 100644 tests/auto/qxmlsimplereader/xmldocs/valid/ext-sa/015.xml.ref diff --git a/src/xml/sax/qxml.cpp b/src/xml/sax/qxml.cpp index 2f5384b..0c7f2ab 100644 --- a/src/xml/sax/qxml.cpp +++ b/src/xml/sax/qxml.cpp @@ -7748,7 +7748,13 @@ bool QXmlSimpleReaderPrivate::processReference() return false; } if (ret) { - QString xmlRefString = ret->data(); + QString xmlRefString; + QString buffer = ret->data(); + while (buffer.length()>0){ + xmlRefString += buffer; + ret->fetchData(); + buffer = ret->data(); + } delete ret; if (!stripTextDecl(xmlRefString)) { reportParseError(QLatin1String(XMLERR_ERRORINTEXTDECL)); diff --git a/tests/auto/qxmlsimplereader/xmldocs/valid/ext-sa/015.ent b/tests/auto/qxmlsimplereader/xmldocs/valid/ext-sa/015.ent new file mode 100755 index 0000000..86a8679 Binary files /dev/null and b/tests/auto/qxmlsimplereader/xmldocs/valid/ext-sa/015.ent differ diff --git a/tests/auto/qxmlsimplereader/xmldocs/valid/ext-sa/015.xml b/tests/auto/qxmlsimplereader/xmldocs/valid/ext-sa/015.xml new file mode 100644 index 0000000..5550dab --- /dev/null +++ b/tests/auto/qxmlsimplereader/xmldocs/valid/ext-sa/015.xml @@ -0,0 +1,6 @@ + + +]> +&e; + diff --git a/tests/auto/qxmlsimplereader/xmldocs/valid/ext-sa/015.xml.ref b/tests/auto/qxmlsimplereader/xmldocs/valid/ext-sa/015.xml.ref new file mode 100644 index 0000000..1ec309a --- /dev/null +++ b/tests/auto/qxmlsimplereader/xmldocs/valid/ext-sa/015.xml.ref @@ -0,0 +1,10 @@ +setDocumentLocator(locator={columnNumber=1, lineNumber=1}) +startDocument() + startDTD(name="doc", publicId="", systemId="") + externalEntityDecl(name="e", publicId="", systemId="015.ent") + endDTD() + startElement(namespaceURI="", localName="doc", qName="doc", atts=[]) + resolveEntity(publicId="", systemId="015.ent", ret={}) + skippedEntity(name="e") + endElement(namespaceURI="", localName="doc", qName="doc") +endDocument() -- cgit v0.12