Kaydet (Commit) a25bec0c authored tarafından Stephan Bergmann's avatar Stephan Bergmann

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
üst 7b01977c
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <rtl/process.h> #include <rtl/process.h>
#include <rtl/string.h> #include <rtl/string.h>
#include <rtl/strbuf.hxx> #include <rtl/strbuf.hxx>
#include <rtl/uri.hxx>
#include <rtl/ustrbuf.hxx> #include <rtl/ustrbuf.hxx>
#include <uno/environment.h> #include <uno/environment.h>
...@@ -58,12 +59,6 @@ ...@@ -58,12 +59,6 @@
#include <osl/thread.h> #include <osl/thread.h>
#include <osl/file.hxx> #include <osl/file.hxx>
#ifdef SAL_UNX
#define SEPARATOR '/'
#else
#define SEPARATOR '\\'
#endif
using namespace std; using namespace std;
using namespace osl; using namespace osl;
using namespace cppu; using namespace cppu;
...@@ -83,42 +78,18 @@ using ::rtl::OUStringBuffer; ...@@ -83,42 +78,18 @@ using ::rtl::OUStringBuffer;
namespace unoexe 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) static OUString convertToFileUrl(const OUString& fileName)
{ {
if ( isFileUrl(fileName) ) OUString uWorkingDir;
{ if (osl_getProcessWorkingDir(&uWorkingDir.pData) != osl_Process_E_None) {
return fileName; OSL_ASSERT(false);
} }
if (!uWorkingDir.isEmpty()
OUString uUrlFileName; && uWorkingDir[uWorkingDir.getLength() - 1] != '/')
if ( fileName.indexOf('.') == 0 || fileName.indexOf(SEPARATOR) < 0 )
{ {
OUString uWorkingDir; 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);
}
} }
return rtl::Uri::convertRelToAbs(uWorkingDir, fileName);
return uUrlFileName;
} }
static sal_Bool s_quiet = false; static sal_Bool s_quiet = false;
...@@ -363,6 +334,13 @@ static Reference< XSimpleRegistry > openRegistry( ...@@ -363,6 +334,13 @@ static Reference< XSimpleRegistry > openRegistry(
out( ": " ); out( ": " );
out( e.Message ); out( e.Message );
} }
catch (rtl::MalformedUriException & e)
{
out( "\n> warning: cannot open registry " );
out( rURL );
out( ": " );
out( e.getMessage() );
}
return Reference< XSimpleRegistry >(); return Reference< XSimpleRegistry >();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment