diff options
author | Michael Stahl <mstahl@redhat.com> | 2017-09-05 22:01:12 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-09-07 11:52:54 +0200 |
commit | 3604ca211204b9a0971a65c96a5075ba43f15693 (patch) | |
tree | 393e89be3d67c7407c1495b5d4d6c114237b1d3a | |
parent | 037d5fa9b129a4060f8f572cb72801b7dfa1608f (diff) |
tdf#112164 sax: handle errors on last call to XML_Parse()
If XML_Parse() is called with isFinal=1 and there are open tags, that is
an error (XML_ERROR_NO_ELEMENTS) that must be converted to an exception.
This reveals that we already had an incomplete input document, which
needs to be moved to "fail" now.
(cherry picked from commit e530a7ddb1c9423487ce936e6b23b8e36449d555)
tdf#112164 add test document
(cherry picked from commit aad2cdce2a2e89f35366c55878129d268cc92bef)
Change-Id: I7ce3b51bd87923b5edde621508cf38d7ebbc2b14
Reviewed-on: https://gerrit.libreoffice.org/41965
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sax/source/expatwrap/sax_expat.cxx | 15 | ||||
-rw-r--r-- | sw/qa/core/data/odt/fail/c2dfc5bd-8366-40e7-b862-55e13fdc52dc.odt | bin | 0 -> 2544 bytes | |||
-rw-r--r-- | sw/qa/core/data/odt/fail/tdf102018.odt (renamed from sw/qa/core/data/odt/pass/tdf102018.odt) | bin | 2851 -> 2851 bytes |
3 files changed, 10 insertions, 5 deletions
diff --git a/sax/source/expatwrap/sax_expat.cxx b/sax/source/expatwrap/sax_expat.cxx index ba87c6f9e146..dfe2246eec19 100644 --- a/sax/source/expatwrap/sax_expat.cxx +++ b/sax/source/expatwrap/sax_expat.cxx @@ -670,18 +670,23 @@ void SaxExpatParser_Impl::parse( ) while( nRead ) { nRead = getEntity().converter.readAndConvert( seqOut , nBufSize ); + bool bContinue(false); + if( ! nRead ) { - XML_Parse( getEntity().pParser , + // last call - must return OK + XML_Status const ret = XML_Parse( getEntity().pParser, reinterpret_cast<const char *>(seqOut.getConstArray()), 0 , 1 ); - break; - } - - bool bContinue = ( XML_Parse( getEntity().pParser , + if (ret == XML_STATUS_OK) { + break; + } + } else { + bContinue = ( XML_Parse( getEntity().pParser, reinterpret_cast<const char *>(seqOut.getConstArray()), nRead, 0 ) != XML_STATUS_ERROR ); + } if( ! bContinue || this->bExceptionWasThrown ) { diff --git a/sw/qa/core/data/odt/fail/c2dfc5bd-8366-40e7-b862-55e13fdc52dc.odt b/sw/qa/core/data/odt/fail/c2dfc5bd-8366-40e7-b862-55e13fdc52dc.odt Binary files differnew file mode 100644 index 000000000000..7cafa8d5e19b --- /dev/null +++ b/sw/qa/core/data/odt/fail/c2dfc5bd-8366-40e7-b862-55e13fdc52dc.odt diff --git a/sw/qa/core/data/odt/pass/tdf102018.odt b/sw/qa/core/data/odt/fail/tdf102018.odt Binary files differindex d804aec11df0..d804aec11df0 100644 --- a/sw/qa/core/data/odt/pass/tdf102018.odt +++ b/sw/qa/core/data/odt/fail/tdf102018.odt |