Commit 69a5df2f authored by Max Kellermann's avatar Max Kellermann

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

This was building broken paths like "/home/foo/~/bar". Bug found by Maarten de Vries.
parent 1c65908c
...@@ -82,10 +82,6 @@ ParsePath(const char *path, Error &error) ...@@ -82,10 +82,6 @@ ParsePath(const char *path, Error &error)
{ {
assert(path != nullptr); assert(path != nullptr);
Path path2 = Path::FromUTF8(path, error);
if (path2.IsNull())
return Path::Null();
#ifndef WIN32 #ifndef WIN32
if (path[0] == '~') { if (path[0] == '~') {
Path home = Path::Null(); Path home = Path::Null();
...@@ -105,12 +101,19 @@ ParsePath(const char *path, Error &error) ...@@ -105,12 +101,19 @@ ParsePath(const char *path, Error &error)
home = GetHome(user, error); home = GetHome(user, error);
g_free(user); g_free(user);
path = slash; if (slash == nullptr)
return home;
path = slash + 1;
} }
if (home.IsNull()) if (home.IsNull())
return Path::Null(); return Path::Null();
Path path2 = Path::FromUTF8(path, error);
if (path2.IsNull())
return Path::Null();
return Path::Build(home, path2); return Path::Build(home, path2);
} else if (!g_path_is_absolute(path)) { } else if (!g_path_is_absolute(path)) {
error.Format(path_domain, error.Format(path_domain,
...@@ -118,7 +121,7 @@ ParsePath(const char *path, Error &error) ...@@ -118,7 +121,7 @@ ParsePath(const char *path, Error &error)
return Path::Null(); return Path::Null();
} else { } else {
#endif #endif
return path2; return Path::FromUTF8(path, error);
#ifndef WIN32 #ifndef WIN32
} }
#endif #endif
......
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