]> granicus.if.org Git - mutt/commitdiff
Add $fcc_before_send, defaulting unset.
authorKevin McCarthy <kevin@8t8.us>
Tue, 11 Jun 2019 20:15:22 +0000 (13:15 -0700)
committerKevin McCarthy <kevin@8t8.us>
Fri, 14 Jun 2019 01:18:47 +0000 (18:18 -0700)
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.

doc/manual.xml.head
init.h
mutt.h
send.c

index 961db38aab29e9138692d36e59878ccb5e02b7ae..01baff28f97e75ee3845e57ed747efe9226e1c28 100644 (file)
@@ -7050,6 +7050,13 @@ macro index ,a "&lt;save-message&gt;=archive&lt;enter&gt;&lt;enter-command&gt;ec
         Message encryption and signing.  Key selection.
       </para>
     </listitem>
+    <listitem>
+      <para>
+        Fcc saving if <link
+        linkend="fcc-before-send">$fcc_before_send</link> is set.  (Note the
+        variable documentation for caveats of Fcc'ing before sending.)
+      </para>
+    </listitem>
     <listitem>
       <para>
         Message sending.
@@ -7057,9 +7064,11 @@ macro index ,a "&lt;save-message&gt;=archive&lt;enter&gt;&lt;enter-command&gt;ec
     </listitem>
     <listitem>
       <para>
-        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 <link
+        linkend="fcc-before-send">$fcc_before_send</link> 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.
       </para>
     </listitem>
   </itemizedlist>
diff --git a/init.h b/init.h
index 79c1ff5185ea98df8bb7c1fc4028a9a720652af0..cc8c7f47c1eaa6af22d750a2c5b291d1d4f2da16 100644 (file)
--- 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 71b666579cbcec574821f14da33a81a0ff96f20d..46302cca012d8a657db85f27670a04341f1f61ad 100644 (file)
--- 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 e1c9d2f49d37ad42b815e42f438d32d85649d2d8..2471d242ace7950079c22a971885be8ebd69ea09 100644 (file)
--- 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))
   {