[Libreoffice-commits] core.git: sw/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Fri Mar 27 16:36:37 UTC 2020


 sw/source/filter/ww8/docxattributeoutput.cxx |   10 ++++++++++
 1 file changed, 10 insertions(+)

New commits:
commit 65284c03757f70478f04aedd4ed7f4062a7c5516
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Fri Mar 27 13:49:09 2020 +0100
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Fri Mar 27 17:35:56 2020 +0100

    sw: DOCX export: ignore linked image with invalid URL
    
    Word 2013 refuses to open DOCX files with image urls that contain %5C
    (encoded '\') in path or query (fragment is not a problem).
    
    Just don't export such images, they won't work anyway.
    
    Change-Id: Iae918791beb8532e76b4f29d49eba6fe0eda8aa8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91204
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index b2828c2a495c..abc70fcc2bbc 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -4861,6 +4861,16 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size
         OUString aFileName;
         pGrfNode->GetFileFilterNms( &aFileName, nullptr );
 
+        sal_Int32 const nFragment(aFileName.indexOf('#'));
+        sal_Int32 const nForbiddenU(aFileName.indexOf("%5C"));
+        sal_Int32 const nForbiddenL(aFileName.indexOf("%5c"));
+        if (   (nForbiddenU != -1 && (nFragment == -1 || nForbiddenU < nFragment))
+            || (nForbiddenL != -1 && (nFragment == -1 || nForbiddenL < nFragment)))
+        {
+            SAL_WARN("sw.ww8", "DocxAttributeOutput::FlyFrameGraphic: ignoring image with invalid link URL");
+            return;
+        }
+
         // TODO Convert the file name to relative for better interoperability
 
         aRelId = m_rExport.AddRelation(


More information about the Libreoffice-commits mailing list