f325b2
From 203eaebd472da9d8c83493331af698b2f9811b55 Mon Sep 17 00:00:00 2001
f325b2
From: Jan Holesovsky <kendy@collabora.com>
f325b2
Date: Mon, 6 Jul 2015 15:16:56 +0200
f325b2
Subject: [PATCH 066/398] LOK: Cleanup absolutizing of URLs.
f325b2
f325b2
Thanks to Stephan Bergmann.
f325b2
f325b2
Change-Id: I22aa3bb827db28bce3eabebb9b8c514663fad860
f325b2
(cherry picked from commit b183507ee293d8bcafa9c1c5b2844b7a83fea17b)
f325b2
---
f325b2
 desktop/source/lib/init.cxx | 32 +++++++++++++++++++++++---------
f325b2
 1 file changed, 23 insertions(+), 9 deletions(-)
f325b2
f325b2
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
f325b2
index c08f1eec85de..63fe90b585b2 100644
f325b2
--- a/desktop/source/lib/init.cxx
f325b2
+++ b/desktop/source/lib/init.cxx
f325b2
@@ -166,19 +166,21 @@ static OUString getUString(const char* pString)
f325b2
 static OUString getAbsoluteURL(const char* pURL)
f325b2
 {
f325b2
     OUString aURL(getUString(pURL));
f325b2
-
f325b2
-    // return unchanged if it likely is an URL already
f325b2
-    if (aURL.indexOf("://") > 0)
f325b2
+    if (aURL.isEmpty())
f325b2
         return aURL;
f325b2
 
f325b2
-    OUString sAbsoluteDocUrl, sWorkingDir, sDocPathUrl;
f325b2
-
f325b2
     // convert relative paths to absolute ones
f325b2
-    osl_getProcessWorkingDir(&sWorkingDir.pData);
f325b2
-    osl::FileBase::getFileURLFromSystemPath( aURL, sDocPathUrl );
f325b2
-    osl::FileBase::getAbsoluteFileURL(sWorkingDir, sDocPathUrl, sAbsoluteDocUrl);
f325b2
+    OUString aWorkingDir;
f325b2
+    osl_getProcessWorkingDir(&aWorkingDir.pData);
f325b2
+
f325b2
+    try {
f325b2
+        return rtl::Uri::convertRelToAbs(aWorkingDir + "/", aURL);
f325b2
+    }
f325b2
+    catch (const rtl::MalformedUriException &)
f325b2
+    {
f325b2
+    }
f325b2
 
f325b2
-    return sAbsoluteDocUrl;
f325b2
+    return OUString();
f325b2
 }
f325b2
 
f325b2
 extern "C"
f325b2
@@ -350,6 +352,12 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions(LibreOfficeKit* pThis,
f325b2
     SolarMutexGuard aGuard;
f325b2
 
f325b2
     OUString aURL(getAbsoluteURL(pURL));
f325b2
+    if (aURL.isEmpty())
f325b2
+    {
f325b2
+        pLib->maLastExceptionMsg = "Filename to load was not provided.";
f325b2
+        SAL_INFO("lok", "URL for load is empty");
f325b2
+        return NULL;
f325b2
+    }
f325b2
 
f325b2
     pLib->maLastExceptionMsg.clear();
f325b2
 
f325b2
@@ -416,6 +424,12 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const cha
f325b2
 
f325b2
     OUString sFormat = getUString(pFormat);
f325b2
     OUString aURL(getAbsoluteURL(sUrl));
f325b2
+    if (aURL.isEmpty())
f325b2
+    {
f325b2
+        gImpl->maLastExceptionMsg = "Filename to save to was not provided.";
f325b2
+        SAL_INFO("lok", "URL for save is empty");
f325b2
+        return false;
f325b2
+    }
f325b2
 
f325b2
     try
f325b2
     {
f325b2
-- 
f325b2
2.12.0
f325b2