diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2017-07-18 22:44:33 +0900 |
---|---|---|
committer | Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> | 2017-09-26 13:11:53 +0200 |
commit | 959e1b409b01ffcf80ed091724fa51a54e97c3c7 (patch) | |
tree | 6adcab6c99aeb50512aff7132bbc9d8a64eeb708 | |
parent | 7509927b9e54c9b249a6a01adc02e8ebcbaf62f4 (diff) |
sax: Check if it starts with 5 bytes of "<?xml"
Reviewed-on: https://gerrit.libreoffice.org/40139
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
(cherry picked from commit b64e564492220b34c14f069e8e1f42675bd9abe6)
ofz: string has to be at least 5 chars long
Reviewed-on: https://gerrit.libreoffice.org/42379
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
this should presumably be 5, rather than 4
Change-Id: Iec5b748b188c7b1bf61e8137faf4b3f2d480d7f1
98c50a59c03fc886d50362b9c5dd8c84f60e0b62
20c6a6fb34485f42c2a828618e8918d8a441860a
Reviewed-on: https://gerrit.libreoffice.org/42396
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Tested-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
-rw-r--r-- | sax/source/expatwrap/xml2utf.cxx | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/sax/source/expatwrap/xml2utf.cxx b/sax/source/expatwrap/xml2utf.cxx index 6ccecc684983..c37f7d3a0c8e 100644 --- a/sax/source/expatwrap/xml2utf.cxx +++ b/sax/source/expatwrap/xml2utf.cxx @@ -125,7 +125,7 @@ XMLFile2UTFConverter::~XMLFile2UTFConverter() void XMLFile2UTFConverter::removeEncoding( Sequence<sal_Int8> &seq ) { const sal_Int8 *pSource = seq.getArray(); - if( ! strncmp( reinterpret_cast<const char *>(pSource), "<?xml", 4) ) + if (seq.getLength() >= 5 && !strncmp(reinterpret_cast<const char *>(pSource), "<?xml", 5)) { // scan for encoding @@ -160,7 +160,6 @@ void XMLFile2UTFConverter::removeEncoding( Sequence<sal_Int8> &seq ) &( seq.getArray()[nStop+1]) , seq.getLength() - nStop -1); seq.realloc( seq.getLength() - ( nStop+1 - nFound ) ); -// str = String( (char * ) seq.getArray() , seq.getLen() ); } } } @@ -177,7 +176,7 @@ bool XMLFile2UTFConverter::isEncodingRecognizable( const Sequence< sal_Int8 > &s return false; } - if( ! strncmp( reinterpret_cast<const char *>(pSource), "<?xml", 4 ) ) { + if( ! strncmp( reinterpret_cast<const char *>(pSource), "<?xml", 5 ) ) { // scan if the <?xml tag finishes within this buffer bCheckIfFirstClosingBracketExsists = true; } @@ -222,8 +221,7 @@ bool XMLFile2UTFConverter::scanForEncoding( Sequence< sal_Int8 > &seq ) } // first level : detect possible file formats - if( ! strncmp( reinterpret_cast<const char *>(pSource), "<?xml", 4 ) ) { - + if (seq.getLength() >= 5 && !strncmp(reinterpret_cast<const char *>(pSource), "<?xml", 5)) { // scan for encoding OString str( reinterpret_cast<const char *>(pSource), seq.getLength() ); |