Here's a better patch.  It preserves the behavior of setting an empty
pgp_sign_as while resuming - but only if the S flag is present.

It renames set_signas to set_empty_signas.  mutt_edit_headers() sets
this to false, because it doesn't want just "S" to clear pgp_sign_as.

If there are no comments, I'll push this out in a couple days.

-Kevin
# HG changeset patch
# User Kevin McCarthy <[email protected]>
# Date 1422912317 28800
#      Mon Feb 02 13:25:17 2015 -0800
# Node ID 3f4dc0ce66aed8c47d0e4872db84f8bf88159823
# Parent  1235dd48ef3f87480d62996a216eeca4e09e5e8a
Fix mutt_parse_crypt_hdr() sign_as behavior.

Currently, if a message is postponed with only the E encryption flag,
when it is resumed, pgp_sign_as will be overwritten (with an empty
string).

This intention of the behavior was probably to restore the exact state
of pgp_sign_as upon resuming.  However, if the message wasn't marked for
signing, the state of pgp_sign_as is not known.  This patch changes the
mutt_parse_crypt_hdr() to only set an empty pgp_sign_as if there is an S
flag (and if set_empty_signas is true).

mutt_edit_headers() also uses the function, but it doesn't want to
overwrite pgp_sign_as with just an S flag.  The set_signas parameter is
renamed to (a hopefully clearer) "set_empty_signas".

diff --git a/postpone.c b/postpone.c
--- a/postpone.c
+++ b/postpone.c
@@ -404,17 +404,17 @@
       tmp = tmp->next;
     }
   }
   return (code);
 }
 
 
 
-int mutt_parse_crypt_hdr (const char *p, int set_signas, int crypt_app)
+int mutt_parse_crypt_hdr (const char *p, int set_empty_signas, int crypt_app)
 {
   char smime_cryptalg[LONG_STRING] = "\0";
   char sign_as[LONG_STRING] = "\0", *q;
   int flags = 0;
 
   if (!WithCrypto)
     return 0;
 
@@ -506,21 +506,23 @@
 
   /* the cryptalg field must not be empty */
   if ((WithCrypto & APPLICATION_SMIME) && *smime_cryptalg)
     mutt_str_replace (&SmimeCryptAlg, smime_cryptalg);
 
   /* Set {Smime,Pgp}SignAs, if desired. */
 
   if ((WithCrypto & APPLICATION_PGP) && (crypt_app == APPLICATION_PGP)
-      && (set_signas || *sign_as))
+      && (flags & SIGN)
+      && (set_empty_signas || *sign_as))
     mutt_str_replace (&PgpSignAs, sign_as);
 
   if ((WithCrypto & APPLICATION_SMIME) && (crypt_app == APPLICATION_SMIME)
-      && (set_signas || *sign_as))
+      && (flags & SIGN)
+      && (set_empty_signas || *sign_as))
     mutt_str_replace (&SmimeDefaultKey, sign_as);
 
   return flags;
 }
 
 
 
 int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr,

Attachment: signature.asc
Description: PGP signature

Reply via email to