From b69ee77256dccee0764c07416fe9bc7db9e5a12d Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Sun, 5 Jul 2009 20:51:04 +0200 Subject: Don't replace ~ when we shouldn't Bump glib req to 2.14 to get GRegex, now we only replace ~ with your homedir in an action if it is (at the start of the string or preceded by whitespace) and (at the end of the string or followed by (whitespace or a slash)). (?:^|(?<=[ \t]))~(?=[/ \t$]) Fixes bug #4033. --- parser/parse.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'parser') diff --git a/parser/parse.c b/parser/parse.c index 636b451f..ed66f088 100644 --- a/parser/parse.c +++ b/parser/parse.c @@ -456,14 +456,16 @@ void parse_paths_shutdown(void) gchar *parse_expand_tilde(const gchar *f) { - gchar **spl; gchar *ret; + GRegex *regex; if (!f) return NULL; - spl = g_strsplit(f, "~", 0); - ret = g_strjoinv(g_get_home_dir(), spl); - g_strfreev(spl); + + regex = g_regex_new("(?:^|(?<=[ \\t]))~(?=[/ \\t$])", G_REGEX_MULTILINE | G_REGEX_RAW, 0, NULL); + ret = g_regex_replace_literal(regex, f, -1, 0, g_get_home_dir(), 0, NULL); + g_regex_unref(regex); + return ret; } -- cgit v1.2.3