ConfigPath: remove the "~/" from the constructed path

This was building broken paths like "/home/foo/~/bar".  Bug found by
Maarten de Vries.
This commit is contained in:
Max Kellermann 2013-09-12 10:26:52 +02:00
parent 1c65908cdb
commit 69a5df2f98

View File

@ -82,10 +82,6 @@ ParsePath(const char *path, Error &error)
{
assert(path != nullptr);
Path path2 = Path::FromUTF8(path, error);
if (path2.IsNull())
return Path::Null();
#ifndef WIN32
if (path[0] == '~') {
Path home = Path::Null();
@ -105,12 +101,19 @@ ParsePath(const char *path, Error &error)
home = GetHome(user, error);
g_free(user);
path = slash;
if (slash == nullptr)
return home;
path = slash + 1;
}
if (home.IsNull())
return Path::Null();
Path path2 = Path::FromUTF8(path, error);
if (path2.IsNull())
return Path::Null();
return Path::Build(home, path2);
} else if (!g_path_is_absolute(path)) {
error.Format(path_domain,
@ -118,7 +121,7 @@ ParsePath(const char *path, Error &error)
return Path::Null();
} else {
#endif
return path2;
return Path::FromUTF8(path, error);
#ifndef WIN32
}
#endif