summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2020-11-06 13:18:27 -0800
committerKevin McCarthy <kevin@8t8.us>2020-11-06 13:18:27 -0800
commit6704caf444fa9746bc641da2ee3f5477d372e50f (patch)
tree90f65635e024ff43c4f7bc91abba152a78cea48c
parent533c38f4d725a211fac50eac2f22366f126dfd3e (diff)
Don't relative-path expand for fcc-hook and save-hook.
"fcc-hook ~x. \\^" used to work, because mutt_addr_hook() calls mutt_make_string(), which performs backslash expansion. The same would happen for save-hook. Many thanks to Oswald Buddenhagen for reporting the issue.
-rw-r--r--hook.c18
-rw-r--r--muttlib.c5
-rw-r--r--protos.h1
3 files changed, 22 insertions, 2 deletions
diff --git a/hook.c b/hook.c
index 57a0e3af..e5d551fa 100644
--- a/hook.c
+++ b/hook.c
@@ -150,13 +150,27 @@ int mutt_parse_hook (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER
mutt_check_simple (pattern, DefaultHook);
}
- if (data & (MUTT_MBOXHOOK | MUTT_SAVEHOOK))
+ if (data & MUTT_MBOXHOOK)
{
mutt_buffer_expand_path (command);
}
+ else if (data & MUTT_SAVEHOOK)
+ {
+ /* Do not perform relative path expansion. "\^" can be expanded later:
+ * mutt_default_save() => mutt_addr_hook() => mutt_make_string()
+ * which will perform backslash expansion, converting "\^" to "^".
+ * The saving code then calls mutt_buffer_expand_path() after prompting.
+ */
+ mutt_buffer_expand_path_norel (command);
+ }
else if (data & MUTT_FCCHOOK)
{
- mutt_buffer_expand_multi_path (command, FccDelimiter);
+ /* Do not perform relative path expansion "\^" can be expanded later:
+ * mutt_select_fcc() => mutt_addr_hook() => mutt_make_string()
+ * which will perform backslash expansion, converting "\^" to "^".
+ * save_fcc_mailbox_part() then calls mutt_buffer_expand_path() on each part.
+ */
+ mutt_buffer_expand_multi_path_norel (command, FccDelimiter);
}
/* check to make sure that a matching hook doesn't already exist */
diff --git a/muttlib.c b/muttlib.c
index 2054dc7e..ce009fdb 100644
--- a/muttlib.c
+++ b/muttlib.c
@@ -543,6 +543,11 @@ void mutt_buffer_expand_multi_path (BUFFER *src, const char *delimiter)
delimited_buffer_map_join (src, delimiter, mutt_buffer_expand_path);
}
+void mutt_buffer_expand_multi_path_norel (BUFFER *src, const char *delimiter)
+{
+ delimited_buffer_map_join (src, delimiter, mutt_buffer_expand_path_norel);
+}
+
void mutt_buffer_expand_path (BUFFER *src)
{
_mutt_buffer_expand_path (src, 0, 1);
diff --git a/protos.h b/protos.h
index 23f2e6fe..7f8ae6d0 100644
--- a/protos.h
+++ b/protos.h
@@ -144,6 +144,7 @@ void mutt_buffer_expand_path (BUFFER *);
void mutt_buffer_expand_path_norel (BUFFER *);
void _mutt_buffer_expand_path (BUFFER *, int, int);
void mutt_buffer_expand_multi_path (BUFFER *src, const char *delimiter);
+void mutt_buffer_expand_multi_path_norel (BUFFER *src, const char *delimiter);
char *mutt_find_hook (int, const char *);
char *mutt_gecos_name (char *, size_t, struct passwd *);
char *mutt_gen_msgid (void);