64af5b
From f107a8c90168124462ddd00db015810081d4be2f Mon Sep 17 00:00:00 2001
64af5b
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
64af5b
Date: Mon, 12 Aug 2019 20:32:54 +0100
64af5b
Subject: [PATCH 1/2] construct final url from parsed output
64af5b
MIME-Version: 1.0
64af5b
Content-Type: text/plain; charset=UTF-8
64af5b
Content-Transfer-Encoding: 8bit
64af5b
64af5b
Change-Id: Ifd733625a439685ad307603eb2b00bf463eb9ca9
64af5b
Reviewed-on: https://gerrit.libreoffice.org/77373
64af5b
Tested-by: Jenkins
64af5b
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
64af5b
(cherry picked from commit 87959e5deea6d33cd35dbb3b8423056f9566710e)
64af5b
Reviewed-on: https://gerrit.libreoffice.org/77377
64af5b
(cherry picked from commit c03acb9b8a97254cfcf7c45ef920b93b7f1dd344)
64af5b
64af5b
an absolute uri is invalid input
64af5b
64af5b
Change-Id: I392be4282be8ed67e3451b28d2c9f22acd4c87fc
64af5b
Reviewed-on: https://gerrit.libreoffice.org/77564
64af5b
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
64af5b
Tested-by: Stephan Bergmann <sbergman@redhat.com>
64af5b
(cherry picked from commit 3c076e54f736980e208f5c27ecf179aa90aea103)
64af5b
Reviewed-on: https://gerrit.libreoffice.org/77572
64af5b
Tested-by: Jenkins
64af5b
(cherry picked from commit 5445f7ffd09e891b220dabb19cd013bcf591fc08)
64af5b
64af5b
Improve check for absolute URI
64af5b
64af5b
Change-Id: I4dee44832107f72f8f3fb68554428dc1e646c346
64af5b
Reviewed-on: https://gerrit.libreoffice.org/77706
64af5b
Tested-by: Jenkins
64af5b
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
64af5b
(cherry picked from commit c79efeb66f7951305d0334bc288aee1c571a8728)
64af5b
Reviewed-on: https://gerrit.libreoffice.org/77724
64af5b
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
64af5b
Tested-by: Caolán McNamara <caolanm@redhat.com>
64af5b
(cherry picked from commit 52f7aa318722bd17c77ee5c4fa8307936e7b53af)
64af5b
---
64af5b
 scripting/source/pyprov/pythonscript.py | 17 +++++++++++++++--
64af5b
 1 file changed, 15 insertions(+), 2 deletions(-)
64af5b
64af5b
diff --git a/scripting/source/pyprov/pythonscript.py b/scripting/source/pyprov/pythonscript.py
64af5b
index 64e1337d642e..acb6184bf437 100644
64af5b
--- a/scripting/source/pyprov/pythonscript.py
64af5b
+++ b/scripting/source/pyprov/pythonscript.py
64af5b
@@ -224,13 +224,24 @@ class MyUriHelper:
64af5b
             sStorageUri = sStorageUri.replace( "|", "/" )
64af5b
 
64af5b
             # path to the .py file, relative to the base
64af5b
-            sFileUri = sStorageUri[0:sStorageUri.find("$")]
64af5b
+            funcNameStart = sStorageUri.find("$")
64af5b
+            if funcNameStart != -1:
64af5b
+                sFileUri = sStorageUri[0:funcNameStart]
64af5b
+                sFuncName = sStorageUri[funcNameStart+1:]
64af5b
+            else:
64af5b
+                sFileUri = sStorageUri
64af5b
+
64af5b
             xFileUri = self.m_uriRefFac.parse(sFileUri)
64af5b
             if not xFileUri:
64af5b
                 message = "pythonscript: invalid relative uri '" + sFileUri+ "'"
64af5b
                 log.debug( message )
64af5b
                 raise RuntimeException( message )
64af5b
 
64af5b
+            if not xFileUri.hasRelativePath():
64af5b
+                message = "pythonscript: an absolute uri is invalid '" + sFileUri+ "'"
64af5b
+                log.debug( message )
64af5b
+                raise RuntimeException( message )
64af5b
+
64af5b
             # absolute path to the .py file
64af5b
             xAbsScriptUri = self.m_uriRefFac.makeAbsolute(xBaseUri, xFileUri, True, RETAIN)
64af5b
             sAbsScriptUri = xAbsScriptUri.getUriReference()
64af5b
@@ -241,7 +252,9 @@ class MyUriHelper:
64af5b
                 log.debug( message )
64af5b
                 raise RuntimeException( message )
64af5b
 
64af5b
-            ret = sBaseUri + sStorageUri
64af5b
+            ret = sAbsScriptUri
64af5b
+            if funcNameStart != -1:
64af5b
+                ret = ret + "$" + sFuncName
64af5b
             log.debug( "converting scriptURI="+scriptURI + " to storageURI=" + ret )
64af5b
             return ret
64af5b
         except UnoException as e:
64af5b
-- 
64af5b
2.21.0
64af5b