From 8304cb8e4ca4bf53daa1da7d2eed9e72ab7502c8 Mon Sep 17 00:00:00 2001 From: feral_hedgehog Date: Sat, 26 Jan 2019 01:40:15 +0200 Subject: [PATCH] Properly expand '~' in mpd_host when preceded by a password. --- src/configuration.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/configuration.cpp b/src/configuration.cpp index 005b27ee..0a2db4a3 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -63,8 +63,12 @@ std::string xdg_config_home() void expand_home(std::string &path) { assert(env_home != nullptr); - if (!path.empty() && path[0] == '~') - path.replace(0, 1, env_home); + if (!path.empty()) + { + size_t i = path.find("~"); + if (i != std::string::npos && (i == 0 || path[i - 1] == '@')) + path.replace(i, 1, env_home); + } } bool configure(int argc, char **argv)