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