From a25bec0cb20671a8a8e2eacd61138773f4275875 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 18 Dec 2012 14:38:39 +0100 Subject: Properly absolutize all registry arguments of uno executable What was found to not work is something like "-ro services.rdb" referencing an XML-format services.rdb that itself contains relative uri attributes. The uno executable would not make an absolute file URL from "services.rdb" due to no leading ".", so trying to absolutize any relative uri attributes against the relative .rdb URL lead to MalformedUriExceptions. Change-Id: Ib41fc8e42b9848f5e77f44c86e1857a3d287d634 --- cpputools/source/unoexe/unoexe.cxx | 52 +++++++++++--------------------------- 1 file changed, 15 insertions(+), 37 deletions(-) diff --git a/cpputools/source/unoexe/unoexe.cxx b/cpputools/source/unoexe/unoexe.cxx index e6590a3fedfc..20256aee38fc 100644 --- a/cpputools/source/unoexe/unoexe.cxx +++ b/cpputools/source/unoexe/unoexe.cxx @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -58,12 +59,6 @@ #include #include -#ifdef SAL_UNX -#define SEPARATOR '/' -#else -#define SEPARATOR '\\' -#endif - using namespace std; using namespace osl; using namespace cppu; @@ -83,42 +78,18 @@ using ::rtl::OUStringBuffer; namespace unoexe { -static sal_Bool isFileUrl(const OUString& fileName) -{ - if (fileName.indexOf("file://") == 0 ) - return sal_True; - return sal_False; -} - static OUString convertToFileUrl(const OUString& fileName) { - if ( isFileUrl(fileName) ) - { - return fileName; + OUString uWorkingDir; + if (osl_getProcessWorkingDir(&uWorkingDir.pData) != osl_Process_E_None) { + OSL_ASSERT(false); } - - OUString uUrlFileName; - if ( fileName.indexOf('.') == 0 || fileName.indexOf(SEPARATOR) < 0 ) + if (!uWorkingDir.isEmpty() + && uWorkingDir[uWorkingDir.getLength() - 1] != '/') { - OUString uWorkingDir; - if (osl_getProcessWorkingDir(&uWorkingDir.pData) != osl_Process_E_None) { - OSL_ASSERT(false); - } - if (FileBase::getAbsoluteFileURL(uWorkingDir, fileName, uUrlFileName) - != FileBase::E_None) - { - OSL_ASSERT(false); - } - } else - { - if (FileBase::getFileURLFromSystemPath(fileName, uUrlFileName) - != FileBase::E_None) - { - OSL_ASSERT(false); - } + uWorkingDir += "/"; } - - return uUrlFileName; + return rtl::Uri::convertRelToAbs(uWorkingDir, fileName); } static sal_Bool s_quiet = false; @@ -363,6 +334,13 @@ static Reference< XSimpleRegistry > openRegistry( out( ": " ); out( e.Message ); } + catch (rtl::MalformedUriException & e) + { + out( "\n> warning: cannot open registry " ); + out( rURL ); + out( ": " ); + out( e.getMessage() ); + } return Reference< XSimpleRegistry >(); } -- cgit