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