diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-12-19 11:13:34 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-12-19 11:19:49 +0100 |
commit | e43fd91b5165a219a4b811209c7efad17379308f (patch) | |
tree | b6f73dc261fe704e9946a33ec2191dedf10aa6df | |
parent | 174b6db5a01314c1651e0787272669950d1be823 (diff) |
Fix for making absolute the registry arguments of the uno executable
a25bec0cb20671a8a8e2eacd61138773f4275875 "Properly absolutize all registry
arguments of uno executable" at least broke testtools/CustomTarget_uno_test.mk
on Windows, where some -ro argument system path starting with a drive letter
("C:/...") is passed in, which rtl::Uri::convertRelToAbs mis-interprets as a
URI with scheme "c".
Switching to osl::FileBase::getAbsoluteFileURL started to break Linux, where
osl_getAbsoluteFileURL for whatever reason calls
osl::FileBase::getSystemPathFromFileURL, which in turn for whetever reason
rejects relative input that starts with "/". The easiest fix that appears not
to break anything else appears to be the workaround now added to
osl_getAbsoluteFileURL.
Change-Id: If03e7136ecc2c26a8f31e591257b1886f3ab129b
-rw-r--r-- | cpputools/source/unoexe/unoexe.cxx | 17 | ||||
-rw-r--r-- | sal/osl/unx/file_url.cxx | 12 |
2 files changed, 16 insertions, 13 deletions
diff --git a/cpputools/source/unoexe/unoexe.cxx b/cpputools/source/unoexe/unoexe.cxx index 54d02de0b721..f657c8983fdc 100644 --- a/cpputools/source/unoexe/unoexe.cxx +++ b/cpputools/source/unoexe/unoexe.cxx @@ -29,7 +29,6 @@ #include <rtl/process.h> #include <rtl/string.h> #include <rtl/strbuf.hxx> -#include <rtl/uri.hxx> #include <rtl/ustrbuf.hxx> #include <uno/environment.h> @@ -84,12 +83,13 @@ static OUString convertToFileUrl(const OUString& fileName) if (osl_getProcessWorkingDir(&uWorkingDir.pData) != osl_Process_E_None) { OSL_ASSERT(false); } - if (!uWorkingDir.isEmpty() - && uWorkingDir[uWorkingDir.getLength() - 1] != '/') + OUString uUrlFileName; + if (FileBase::getAbsoluteFileURL(uWorkingDir, fileName, uUrlFileName) + != FileBase::E_None) { - uWorkingDir += "/"; + OSL_ASSERT(false); } - return rtl::Uri::convertRelToAbs(uWorkingDir, fileName); + return uUrlFileName; } static sal_Bool s_quiet = false; @@ -334,13 +334,6 @@ 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 >(); } diff --git a/sal/osl/unx/file_url.cxx b/sal/osl/unx/file_url.cxx index 082f85cfa051..7c28b8ca4ca9 100644 --- a/sal/osl/unx/file_url.cxx +++ b/sal/osl/unx/file_url.cxx @@ -675,10 +675,20 @@ namespace /* private */ oslFileError osl_getAbsoluteFileURL(rtl_uString* ustrBaseDirURL, rtl_uString* ustrRelativeURL, rtl_uString** pustrAbsoluteURL) { + // Work around the below call to getSystemPathFromFileURL rejecting input + // that starts with "/" (for whatever reason it behaves that way; but + // changing that would start to break lots of tests at least): + rtl::OUString relUrl(ustrRelativeURL); + if (relUrl.startsWith("//")) { + relUrl = "file:" + relUrl; + } else if (relUrl.startsWith("/")) { + relUrl = "file://" + relUrl; + } + FileBase::RC rc; rtl::OUString unresolved_path; - rc = FileBase::getSystemPathFromFileURL(rtl::OUString(ustrRelativeURL), unresolved_path); + rc = FileBase::getSystemPathFromFileURL(relUrl, unresolved_path); if(FileBase::E_None != rc) return oslFileError(rc); |