diff options
author | Max Kellermann <max@duempel.org> | 2013-09-12 10:26:52 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-09-12 10:54:45 +0200 |
commit | 69a5df2f98672b79fe28ba46db5338f132a6555b (patch) | |
tree | ccc4385ad22314ba7a1a074e33e2cf6af9f51cc1 /src | |
parent | 1c65908cdb1559d7dc7ebbf93d2e1eb9b94197e0 (diff) | |
download | mpd-69a5df2f98672b79fe28ba46db5338f132a6555b.tar.gz mpd-69a5df2f98672b79fe28ba46db5338f132a6555b.tar.xz mpd-69a5df2f98672b79fe28ba46db5338f132a6555b.zip |
ConfigPath: remove the "~/" from the constructed path
This was building broken paths like "/home/foo/~/bar". Bug found by
Maarten de Vries.
Diffstat (limited to 'src')
-rw-r--r-- | src/ConfigPath.cxx | 15 |
1 files changed, 9 insertions, 6 deletions
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 |