64af5b
From 292fe2f32df0e9096e63383eb45924eceb2179db Mon Sep 17 00:00:00 2001
64af5b
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
64af5b
Date: Tue, 23 Jul 2019 15:31:05 +0100
64af5b
Subject: [PATCH 2/3] expand LibreLogo check to global events
64af5b
MIME-Version: 1.0
64af5b
Content-Type: text/plain; charset=UTF-8
64af5b
Content-Transfer-Encoding: 8bit
64af5b
64af5b
Reviewed-on: https://gerrit.libreoffice.org/76189
64af5b
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
64af5b
Tested-by: Caolán McNamara <caolanm@redhat.com>
64af5b
(cherry picked from commit 4a66c7eda6ccde26a42c4e31725248c59940255d)
64af5b
64af5b
Change-Id: I7f436983ba0eb4b76b02d08ee52626e54b103d5f
64af5b
Reviewed-on: https://gerrit.libreoffice.org/76305
64af5b
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
64af5b
Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
64af5b
---
64af5b
 include/sfx2/objsh.hxx               |  2 ++
64af5b
 sfx2/source/doc/objmisc.cxx          |  6 +-----
64af5b
 sfx2/source/notify/eventsupplier.cxx | 18 ++++++++++++------
64af5b
 3 files changed, 15 insertions(+), 11 deletions(-)
64af5b
64af5b
diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
64af5b
index d04758567c80..ed09fc6e2acb 100644
64af5b
--- a/include/sfx2/objsh.hxx
64af5b
+++ b/include/sfx2/objsh.hxx
64af5b
@@ -404,6 +404,8 @@ public:
64af5b
     */
64af5b
     bool                        AdjustMacroMode();
64af5b
 
64af5b
+    static bool                 UnTrustedScript(const OUString& rScriptURL);
64af5b
+
64af5b
     SvKeyValueIterator*         GetHeaderAttributes();
64af5b
     void                        ClearHeaderAttributesForSourceViewHack();
64af5b
     void                        SetHeaderAttributesForSourceViewHack();
64af5b
diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx
64af5b
index 7e9288524b34..9b82742302ab 100644
64af5b
--- a/sfx2/source/doc/objmisc.cxx
64af5b
+++ b/sfx2/source/doc/objmisc.cxx
64af5b
@@ -1348,10 +1348,8 @@ namespace
64af5b
     }
64af5b
 }
64af5b
 
64af5b
-namespace {
64af5b
-
64af5b
 // don't allow LibreLogo to be used with our mouseover/etc dom-alike events
64af5b
-bool UnTrustedScript(const OUString& rScriptURL)
64af5b
+bool SfxObjectShell::UnTrustedScript(const OUString& rScriptURL)
64af5b
 {
64af5b
     if (!rScriptURL.startsWith("vnd.sun.star.script:"))
64af5b
         return false;
64af5b
@@ -1382,8 +1380,6 @@ bool UnTrustedScript(const OUString& rScriptURL)
64af5b
     return false;
64af5b
 }
64af5b
 
64af5b
-}
64af5b
-
64af5b
 ErrCode SfxObjectShell::CallXScript( const Reference< XInterface >& _rxScriptContext, const OUString& _rScriptURL,
64af5b
     const Sequence< Any >& aParams, Any& aRet, Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam, bool bRaiseError, const css::uno::Any* pCaller )
64af5b
 {
64af5b
diff --git a/sfx2/source/notify/eventsupplier.cxx b/sfx2/source/notify/eventsupplier.cxx
64af5b
index 78667a1d8036..2656e9c213ec 100644
64af5b
--- a/sfx2/source/notify/eventsupplier.cxx
64af5b
+++ b/sfx2/source/notify/eventsupplier.cxx
64af5b
@@ -207,18 +207,24 @@ void SfxEvents_Impl::Execute( uno::Any const & aEventData, const document::Docum
64af5b
         else if (aType == "Service" ||
64af5b
                   aType == "Script")
64af5b
         {
64af5b
-            if ( !aScript.isEmpty() )
64af5b
+            bool bAllowed = false;
64af5b
+            util::URL aURL;
64af5b
+            if (!aScript.isEmpty())
64af5b
             {
64af5b
-                SfxViewFrame* pView = pDoc ?
64af5b
-                    SfxViewFrame::GetFirst( pDoc ) :
64af5b
-                    SfxViewFrame::Current();
64af5b
-
64af5b
                 uno::Reference < util::XURLTransformer > xTrans( util::URLTransformer::create( ::comphelper::getProcessComponentContext() ) );
64af5b
 
64af5b
-                util::URL aURL;
64af5b
                 aURL.Complete = aScript;
64af5b
                 xTrans->parseStrict( aURL );
64af5b
 
64af5b
+                bAllowed = !SfxObjectShell::UnTrustedScript(aURL.Complete);
64af5b
+            }
64af5b
+
64af5b
+            if (bAllowed)
64af5b
+            {
64af5b
+                SfxViewFrame* pView = pDoc ?
64af5b
+                    SfxViewFrame::GetFirst( pDoc ) :
64af5b
+                    SfxViewFrame::Current();
64af5b
+
64af5b
                 uno::Reference
64af5b
                     < frame::XDispatchProvider > xProv;
64af5b
 
64af5b
-- 
64af5b
2.21.0
64af5b