From d89f4a616f3453c092f7b0b1f2764925ea4d4230 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Wed, 16 Aug 2017 13:47:57 +0100 Subject: [PATCH] trim trailing slash from completed dirs When saving a email, selecting a maildir directory should override the setting of $mbox_type. Fixes #719 --- commands.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/commands.c b/commands.c index e97a2c509..2f9bbc883 100644 --- a/commands.c +++ b/commands.c @@ -801,9 +801,14 @@ int mutt_save_message(struct Header *h, int delete, int decode, int decrypt) if (mutt_enter_fname(prompt, buf, sizeof(buf), 0) == -1) return -1; - if (!buf[0]) + size_t pathlen = strlen(buf); + if (pathlen == 0) return -1; + /* Trim any trailing '/' */ + if (buf[pathlen - 1] == '/') + buf[pathlen - 1] = '\0'; + /* This is an undocumented feature of ELM pointed out to me by Felix von * Leitner */ @@ -812,15 +817,6 @@ int mutt_save_message(struct Header *h, int delete, int decode, int decrypt) else strfcpy(LastSaveFolder, buf, sizeof(LastSaveFolder)); - /* check if path is a filename by comparing last character - * (mboxes need filenames, not directories) - */ - if (DefaultMagic == MUTT_MBOX && buf[strlen(buf) - 1] == '/') - { - mutt_error(_("'%s' is a directory, need a filename for mbox."), buf); - return -1; - } - mutt_expand_path(buf, sizeof(buf)); /* check to make sure that this file is really the one the user wants */ -- 2.40.0