svg export: check text hyperlink URLs the same way as shape ones

and have the slideshow open only http, https and mailto links

same check as:

commit 34ec465717
Date:   Mon Mar 4 09:38:02 2019 +0100

    Check svg URLs before exporting

text hyperlinks exported since:

commit b76628acb1
Date:   Sat Aug 11 22:23:22 2012 +0200

    text export support for bullets and hyperlinks

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I826ffb43f0e809f91d1728a9a3b39ebec5b83d6e
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/13498
Reviewed-by: Noel Grandin <noel.grandin@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
(cherry picked from commit 5f9e522ae9b43a9f4777d86accd20cce02d8fad3)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211595
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
Caolán McNamara
2026-09-30 11:48:43 +02:00
committed by Xisco Fauli
parent f3f25e07f9
commit 5a201620b2
2 changed files with 21 additions and 2 deletions
+11 -1
View File
@@ -16217,7 +16217,17 @@ HyperlinkElement.prototype.handleClick = function( )
var aWindowObject = document.defaultView; var aWindowObject = document.defaultView;
if( aWindowObject ) 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 else
{ {
+10 -1
View File
@@ -37,6 +37,7 @@
#include <tools/fract.hxx> #include <tools/fract.hxx>
#include <tools/helpers.hxx> #include <tools/helpers.hxx>
#include <tools/stream.hxx> #include <tools/stream.hxx>
#include <tools/urlobj.hxx>
#include <xmloff/namespacemap.hxx> #include <xmloff/namespacemap.hxx>
#include <xmloff/unointerfacetouniqueidentifiermapper.hxx> #include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
#include <i18nlangtag/languagetag.hxx> #include <i18nlangtag/languagetag.hxx>
@@ -1309,7 +1310,15 @@ bool SVGTextWriter::nextTextPortion()
#if OSL_DEBUG_LEVEL > 0 #if OSL_DEBUG_LEVEL > 0
sInfo += "url: " + mrExport.GetRelativeReference( sURL ); sInfo += "url: " + mrExport.GetRelativeReference( sURL );
#endif #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() ) if( !msUrl.isEmpty() )
{ {
implRegisterInterface( xPortionTextRange ); implRegisterInterface( xPortionTextRange );