From 5a201620b2c9ec8214b8c42b75bee0b2d953014c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Thu, 24 Sep 2026 20:09:09 +0000 Subject: [PATCH] svg export: check text hyperlink URLs the same way as shape ones MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit and have the slideshow open only http, https and mailto links same check as: commit 34ec46571701d639d9bc542b2d19f87a21a83648 Date: Mon Mar 4 09:38:02 2019 +0100 Check svg URLs before exporting text hyperlinks exported since: commit b76628acb1ae4fc06f8c1b70ec2e0cf39356deef Date: Sat Aug 11 22:23:22 2012 +0200 text export support for bullets and hyperlinks Signed-off-by: Caolán McNamara Change-Id: I826ffb43f0e809f91d1728a9a3b39ebec5b83d6e Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/13498 Reviewed-by: Noel Grandin Tested-by: Jenkins CPCI (cherry picked from commit 5f9e522ae9b43a9f4777d86accd20cce02d8fad3) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211595 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- filter/source/svg/presentation_engine.js | 12 +++++++++++- filter/source/svg/svgwriter.cxx | 11 ++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/filter/source/svg/presentation_engine.js b/filter/source/svg/presentation_engine.js index fa42b89b2f8e..c94b07ecce48 100644 --- a/filter/source/svg/presentation_engine.js +++ b/filter/source/svg/presentation_engine.js @@ -16217,7 +16217,17 @@ HyperlinkElement.prototype.handleClick = function( ) var aWindowObject = document.defaultView; if( aWindowObject ) { - aWindowObject.open( this.sURL, this.sId ); + var sProtocol = ''; + try + { + sProtocol = new URL( this.sURL, document.baseURI ).protocol; + } + catch( e ) + { + log( 'error: HyperlinkElement.handleClick: invalid url.' ); + } + if( sProtocol === 'http:' || sProtocol === 'https:' || sProtocol === 'mailto:' ) + aWindowObject.open( this.sURL, this.sId ); } else { diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx index 0c7a631127ad..9d9a6dccbd58 100644 --- a/filter/source/svg/svgwriter.cxx +++ b/filter/source/svg/svgwriter.cxx @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -1309,7 +1310,15 @@ bool SVGTextWriter::nextTextPortion() #if OSL_DEBUG_LEVEL > 0 sInfo += "url: " + mrExport.GetRelativeReference( sURL ); #endif - msUrl = mrExport.GetRelativeReference( sURL ); + // A link to a place in the presentation starts with '#'. + INetURLObject aINetURLObject(sURL); + if (sURL.startsWith("#") + || (!aINetURLObject.HasError() + && !aINetURLObject.IsExoticProtocol() + && aINetURLObject.GetProtocol() != INetProtocol::Javascript)) + msUrl = mrExport.GetRelativeReference( sURL ); + else + msUrl.clear(); if( !msUrl.isEmpty() ) { implRegisterInterface( xPortionTextRange );