[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-1+backports' - 2 commits - scripting/source sfx2/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Wed Aug 7 21:20:50 UTC 2019


 scripting/source/protocolhandler/scripthandler.cxx |    9 ++++++-
 sfx2/source/doc/objmisc.cxx                        |   24 ++++++++++++---------
 2 files changed, 21 insertions(+), 12 deletions(-)

New commits:
commit 0bba7edabf786488c080ac35ff93b308bcb3ad7a
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Aug 7 12:58:01 2019 +0100
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Wed Aug 7 23:20:24 2019 +0200

    expand pyuno path separators
    
    Change-Id: Ic97649ed6d4be595b308922c7bdc880cbb60b239
    Reviewed-on: https://gerrit.libreoffice.org/77102
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
    (cherry picked from commit 75903a0298218f89a199a5ac151ee0166f4469d7)
    Reviewed-on: https://gerrit.libreoffice.org/77118
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx
index fbe7ba9da3ed..de0a6153675d 100644
--- a/sfx2/source/doc/objmisc.cxx
+++ b/sfx2/source/doc/objmisc.cxx
@@ -1362,7 +1362,8 @@ bool SfxObjectShell::UnTrustedScript(const OUString& rScriptURL)
     if (!sfUri.is())
         return false;
 
-    OUString sScript = sfUri->getName();
+    // pyuno encodes path separator as |
+    OUString sScript = sfUri->getName().replace('|', '/');
 
     // check if any path portion matches LibreLogo and ban it if it does
     sal_Int32 nIndex = 0;
commit 42645baa4a2fcd0fe392d9add899f8504b798d47
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Tue Aug 6 13:29:22 2019 +0200
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Wed Aug 7 23:20:09 2019 +0200

    Properly obtain location
    
    Change-Id: I9fb0d883a3623394343cd54ef61e5610544198c8
    Reviewed-on: https://gerrit.libreoffice.org/77019
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
    (cherry picked from commit a9cde2557242a0c343d99533f3ee032599c66f42)
    Reviewed-on: https://gerrit.libreoffice.org/77023
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit 28c6af3ddc283ca9c5712359a9abcb385c1575b4)
    Reviewed-on: https://gerrit.libreoffice.org/77091
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/scripting/source/protocolhandler/scripthandler.cxx b/scripting/source/protocolhandler/scripthandler.cxx
index d238bdbd300d..e7cd12a21f0e 100644
--- a/scripting/source/protocolhandler/scripthandler.cxx
+++ b/scripting/source/protocolhandler/scripthandler.cxx
@@ -47,6 +47,7 @@
 
 #include <com/sun/star/uno/XComponentContext.hpp>
 #include <com/sun/star/uri/XUriReference.hpp>
+#include <com/sun/star/uri/XVndSunStarScriptUrlReference.hpp>
 #include <com/sun/star/uri/UriReferenceFactory.hpp>
 
 #include <memory>
@@ -133,8 +134,12 @@ void SAL_CALL ScriptProtocolHandler::dispatchWithNotification(
     {
         try
         {
-            bool bIsDocumentScript = ( aURL.Complete.indexOf( "document" ) !=-1 );
-                // TODO: isn't this somewhat strange? This should be a test for a location=document parameter, shouldn't it?
+            css::uno::Reference<css::uri::XUriReferenceFactory> urifac(
+                css::uri::UriReferenceFactory::create(m_xContext));
+            css::uno::Reference<css::uri::XVndSunStarScriptUrlReference> uri(
+                urifac->parse(aURL.Complete), css::uno::UNO_QUERY_THROW);
+            auto const loc = uri->getParameter("location");
+            bool bIsDocumentScript = loc == "document";
 
             if ( bIsDocumentScript )
             {
diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx
index 59d3098115b1..fbe7ba9da3ed 100644
--- a/sfx2/source/doc/objmisc.cxx
+++ b/sfx2/source/doc/objmisc.cxx
@@ -1385,19 +1385,22 @@ ErrCode SfxObjectShell::CallXScript( const Reference< XInterface >& _rxScriptCon
     SAL_INFO("sfx", "in CallXScript" );
     ErrCode nErr = ERRCODE_NONE;
 
-    bool bIsDocumentScript = ( _rScriptURL.indexOf( "location=document" ) >= 0 );
-        // TODO: we should parse the URL, and check whether there is a parameter with this name.
-        // Otherwise, we might find too much.
-    if ( bIsDocumentScript && !lcl_isScriptAccessAllowed_nothrow( _rxScriptContext ) )
-        return ERRCODE_IO_ACCESSDENIED;
-
-    if ( UnTrustedScript(_rScriptURL) )
-        return ERRCODE_IO_ACCESSDENIED;
-
     bool bCaughtException = false;
     Any aException;
     try
     {
+        css::uno::Reference<css::uri::XUriReferenceFactory> urifac(
+            css::uri::UriReferenceFactory::create(comphelper::getProcessComponentContext()));
+        css::uno::Reference<css::uri::XVndSunStarScriptUrlReference> uri(
+            urifac->parse(_rScriptURL), css::uno::UNO_QUERY_THROW);
+        auto const loc = uri->getParameter("location");
+        bool bIsDocumentScript = loc == "document";
+        if ( bIsDocumentScript && !lcl_isScriptAccessAllowed_nothrow( _rxScriptContext ) )
+            return ERRCODE_IO_ACCESSDENIED;
+
+        if ( UnTrustedScript(_rScriptURL) )
+            return ERRCODE_IO_ACCESSDENIED;
+
         // obtain/create a script provider
         Reference< provider::XScriptProvider > xScriptProvider;
         Reference< provider::XScriptProviderSupplier > xSPS( _rxScriptContext, UNO_QUERY );


More information about the Libreoffice-commits mailing list