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