Check svg URLs before exporting

Change-Id: I3b86b6b82318b0d201c3d7db516664520eb47bed
Reviewed-on: https://gerrit.libreoffice.org/68668
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
This commit is contained in:
Samuel Mehrbrodt
2019-03-05 08:39:55 +01:00
parent fa10258d72
commit 34ec465717
3 changed files with 28 additions and 7 deletions
+13 -7
View File
@@ -47,6 +47,7 @@
#include <comphelper/sequenceashashmap.hxx>
#include <i18nlangtag/lang.h>
#include <svl/zforlist.hxx>
#include <tools/urlobj.hxx>
#include <unotools/ucbstreamhelper.hxx>
#include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
#include <xmloff/nmspmap.hxx>
@@ -1951,13 +1952,18 @@ bool SVGFilter::implExportShape( const Reference< css::drawing::XShape >& rxShap
if( !aBookmark.isEmpty() )
{
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xlink:href", aBookmark);
SvXMLElementExport alinkA( *mpSVGExport, XML_NAMESPACE_NONE, "a", true, true );
mpSVGWriter->WriteMetaFile( aTopLeft, aSize, rMtf,
0xffffffff,
pElementId,
&rxShape,
pEmbeddedBitmapsMtf );
INetURLObject aINetURLObject(aBookmark);
if (!aINetURLObject.HasError()
&& aINetURLObject.GetProtocol() != INetProtocol::Javascript)
{
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xlink:href", aBookmark);
SvXMLElementExport alinkA( *mpSVGExport, XML_NAMESPACE_NONE, "a", true, true );
mpSVGWriter->WriteMetaFile( aTopLeft, aSize, rMtf,
0xffffffff,
pElementId,
&rxShape,
pEmbeddedBitmapsMtf );
}
}
else
{
+15
View File
@@ -110,8 +110,23 @@ public:
assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[2]/SVG_G/SVG_G/SVG_G/SVG_G/SVG_G[2]/SVG_G/SVG_TEXT/SVG_TSPAN ), "text-decoration", "line-through");
}
void testSVGExportJavascriptURL()
{
executeExport("textbox-link-javascript.odp");
xmlDocPtr svgDoc = parseXml(maTempFile);
CPPUNIT_ASSERT(svgDoc);
// There should be only one child (no link to javascript url)
assertXPathChildren(svgDoc,
MAKE_PATH_STRING(/ SVG_SVG / SVG_G[2] / SVG_G / SVG_G / SVG_G / SVG_G
/ SVG_G[4] / SVG_G),
1);
}
CPPUNIT_TEST_SUITE(SdSVGFilterTest);
CPPUNIT_TEST(testSVGExportTextDecorations);
CPPUNIT_TEST(testSVGExportJavascriptURL);
CPPUNIT_TEST_SUITE_END();
};
Binary file not shown.