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