From 69a5df2f98672b79fe28ba46db5338f132a6555b Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 12 Sep 2013 10:26:52 +0200 Subject: ConfigPath: remove the "~/" from the constructed path This was building broken paths like "/home/foo/~/bar". Bug found by Maarten de Vries. --- src/ConfigPath.cxx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/ConfigPath.cxx') diff --git a/src/ConfigPath.cxx b/src/ConfigPath.cxx index 6bc56b897..85739761c 100644 --- a/src/ConfigPath.cxx +++ b/src/ConfigPath.cxx @@ -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 -- cgit v1.2.3