sw/source/filter/xml/xmlimp.cxx |    8 ++++++++
 1 file changed, 8 insertions(+)

New commits:
commit f5febc2888a26cdd684c9a1590c6ca0b6ff26a4b
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Wed May 10 14:52:58 2023 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Wed May 10 17:39:53 2023 +0200

    Related: ofz#58781 insist on presence of office:mimetype
    
    reject here what full office will reject to generate easily reproducible
    findings.
    
    Change-Id: Ia9a2f7fd3ae32b2623caa8eb9964a8fbd7ee09b2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151636
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
index 49066780635b..2e7f634212f5 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -1775,6 +1775,14 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool 
TestImportFODT(SvStream &rStream)
 
 extern "C" SAL_DLLPUBLIC_EXPORT bool TestPDFExportFODT(SvStream &rStream)
 {
+    // do the same sort of check as FilterDetect::detect
+    OString const str(read_uInt8s_ToOString(rStream, 4000));
+    rStream.Seek(STREAM_SEEK_TO_BEGIN);
+    OUString resultString(str.getStr(), str.getLength(), 
RTL_TEXTENCODING_ASCII_US,
+                          
RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_DEFAULT|OSTRING_TO_OUSTRING_CVTFLAGS);
+    if 
(resultString.indexOf("office:mimetype=\"application/vnd.oasis.opendocument.text\"")
 == -1)
+        return false;
+
     Reference<css::frame::XDesktop2> xDesktop = 
css::frame::Desktop::create(comphelper::getProcessComponentContext());
     Reference<css::frame::XFrame> xTargetFrame = xDesktop->findFrame("_blank", 
0);
 

Reply via email to