diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2020-03-27 13:49:09 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@cib.de> | 2020-03-27 17:35:56 +0100 |
commit | 65284c03757f70478f04aedd4ed7f4062a7c5516 (patch) | |
tree | fbaf7d6621cbdfc5cdb0be213d1f1de6a6bbae9e /sw | |
parent | ea331fa8b498c66ec687c6611c69ffc61e58bc79 (diff) |
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@cib.de>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 10 |
1 files changed, 10 insertions, 0 deletions
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( |