From: Kevin McCarthy Date: Tue, 11 Jun 2019 20:15:22 +0000 (-0700) Subject: Add $fcc_before_send, defaulting unset. X-Git-Tag: mutt-1-12-1-rel~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dc6624743ecbdebabf3b0e35eb2e24a4b9370e80;p=mutt Add $fcc_before_send, defaulting unset. When set, the message will be Fcc'ed the same as sent. $fcc_clear and $fcc_attach will be ignored. This is because of the difficulty of unwinding changes, notably Protected Headers, without potentially breaking signatures. --- diff --git a/doc/manual.xml.head b/doc/manual.xml.head index 961db38a..01baff28 100644 --- a/doc/manual.xml.head +++ b/doc/manual.xml.head @@ -7050,6 +7050,13 @@ macro index ,a "<save-message>=archive<enter><enter-command>ec Message encryption and signing. Key selection. + + + Fcc saving if $fcc_before_send is set. (Note the + variable documentation for caveats of Fcc'ing before sending.) + + Message sending. @@ -7057,9 +7064,11 @@ macro index ,a "<save-message>=archive<enter><enter-command>ec - Fcc saving. Note: prior to version 1.12, the Fcc was saved - before sending the message. It is now saved afterwards, but - if the saving fails, the user is prompted. + Fcc saving if $fcc_before_send is unset + (the default). Note: prior to version 1.12, the Fcc was saved + before sending the message. It is now by default saved + afterwards, but if the saving fails, the user is prompted. diff --git a/init.h b/init.h index 79c1ff51..cc8c7f47 100644 --- a/init.h +++ b/init.h @@ -925,6 +925,20 @@ struct option_t MuttVars[] = { ** This variable controls whether or not attachments on outgoing messages ** are saved along with the main body of your message. */ + { "fcc_before_send", DT_BOOL, R_NONE, OPTFCCBEFORESEND, 0 }, + /* + ** .pp + ** When this variable is \fIset\fP, FCCs will occur before sending + ** the message. Before sending, the message cannot be manipulated, + ** so it will be stored the exact same as sent: + ** $$fcc_attach and $$fcc_clear will be ignored (using their default + ** values). + ** .pp + ** When \fIunset\fP, the default, FCCs will occur after sending. + ** Variables $$fcc_attach and $$fcc_clear will be respected, allowing + ** it to be stored without attachments or encryption/signing if + ** desired. + */ { "fcc_clear", DT_BOOL, R_NONE, OPTFCCCLEAR, 0 }, /* ** .pp diff --git a/mutt.h b/mutt.h index 71b66657..46302cca 100644 --- a/mutt.h +++ b/mutt.h @@ -393,6 +393,7 @@ enum OPTENCODEFROM, OPTENVFROM, OPTFASTREPLY, + OPTFCCBEFORESEND, OPTFCCCLEAR, OPTFLAGSAFE, OPTFOLLOWUPTO, diff --git a/send.c b/send.c index e1c9d2f4..2471d242 100644 --- a/send.c +++ b/send.c @@ -1193,49 +1193,55 @@ static int save_fcc (HEADER *msg, char *fcc, size_t fcc_len, if (!(*fcc && mutt_strcmp ("/dev/null", fcc))) return rc; - if (WithCrypto && (msg->security & (ENCRYPT | SIGN)) && option (OPTFCCCLEAR)) + /* Before sending, we don't allow message manipulation because it + * will break message signatures. This is especially complicated by + * Protected Headers. */ + if (!option (OPTFCCBEFORESEND)) { - msg->content = clear_content; - msg->security &= ~(ENCRYPT | SIGN); - mutt_free_envelope (&msg->content->mime_headers); - } + if (WithCrypto && (msg->security & (ENCRYPT | SIGN)) && option (OPTFCCCLEAR)) + { + msg->content = clear_content; + msg->security &= ~(ENCRYPT | SIGN); + mutt_free_envelope (&msg->content->mime_headers); + } - /* check to see if the user wants copies of all attachments */ - if (query_quadoption (OPT_FCCATTACH, _("Save attachments in Fcc?")) != MUTT_YES && - msg->content->type == TYPEMULTIPART) - { - if (WithCrypto - && (msg->security & (ENCRYPT | SIGN)) - && (mutt_strcmp (msg->content->subtype, "encrypted") == 0 || - mutt_strcmp (msg->content->subtype, "signed") == 0)) + /* check to see if the user wants copies of all attachments */ + if (query_quadoption (OPT_FCCATTACH, _("Save attachments in Fcc?")) != MUTT_YES && + msg->content->type == TYPEMULTIPART) { - if (clear_content->type == TYPEMULTIPART) + if (WithCrypto + && (msg->security & (ENCRYPT | SIGN)) + && (mutt_strcmp (msg->content->subtype, "encrypted") == 0 || + mutt_strcmp (msg->content->subtype, "signed") == 0)) { - if (!(msg->security & ENCRYPT) && (msg->security & SIGN)) + if (clear_content->type == TYPEMULTIPART) { - /* save initial signature and attachments */ - save_sig = msg->content->parts->next; - save_parts = clear_content->parts->next; - } + if (!(msg->security & ENCRYPT) && (msg->security & SIGN)) + { + /* save initial signature and attachments */ + save_sig = msg->content->parts->next; + save_parts = clear_content->parts->next; + } - /* this means writing only the main part */ - msg->content = clear_content->parts; + /* this means writing only the main part */ + msg->content = clear_content->parts; - if (mutt_protect (msg, pgpkeylist) == -1) - { - /* we can't do much about it at this point, so - * fallback to saving the whole thing to fcc - */ - msg->content = tmpbody; - save_sig = NULL; - goto full_fcc; - } + if (mutt_protect (msg, pgpkeylist) == -1) + { + /* we can't do much about it at this point, so + * fallback to saving the whole thing to fcc + */ + msg->content = tmpbody; + save_sig = NULL; + goto full_fcc; + } - save_content = msg->content; + save_content = msg->content; + } } + else + msg->content = msg->content->parts; } - else - msg->content = msg->content->parts; } full_fcc: @@ -1291,26 +1297,29 @@ full_fcc: } } - msg->content = tmpbody; - - if (WithCrypto && save_sig) + if (!option (OPTFCCBEFORESEND)) { - /* cleanup the second signature structures */ - if (save_content->parts) + msg->content = tmpbody; + + if (WithCrypto && save_sig) { - mutt_free_body (&save_content->parts->next); - save_content->parts = NULL; - } - mutt_free_body (&save_content); + /* cleanup the second signature structures */ + if (save_content->parts) + { + mutt_free_body (&save_content->parts->next); + save_content->parts = NULL; + } + mutt_free_body (&save_content); - /* restore old signature and attachments */ - msg->content->parts->next = save_sig; - msg->content->parts->parts->next = save_parts; - } - else if (WithCrypto && save_content) - { - /* destroy the new encrypted body. */ - mutt_free_body (&save_content); + /* restore old signature and attachments */ + msg->content->parts->next = save_sig; + msg->content->parts->parts->next = save_parts; + } + else if (WithCrypto && save_content) + { + /* destroy the new encrypted body. */ + mutt_free_body (&save_content); + } } return rc; @@ -2134,6 +2143,9 @@ main_loop: mutt_prepare_envelope (msg->env, 1); + if (option (OPTFCCBEFORESEND)) + save_fcc (msg, fcc, sizeof(fcc), clear_content, pgpkeylist, flags); + if ((i = send_message (msg)) < 0) { if (!(flags & SENDBATCH)) @@ -2167,7 +2179,8 @@ main_loop: } } - save_fcc (msg, fcc, sizeof(fcc), clear_content, pgpkeylist, flags); + if (!option (OPTFCCBEFORESEND)) + save_fcc (msg, fcc, sizeof(fcc), clear_content, pgpkeylist, flags); if (!option (OPTNOCURSES) && ! (flags & SENDMAILX)) {