From: Kevin McCarthy Date: Mon, 2 Feb 2015 21:25:17 +0000 (-0800) Subject: Fix mutt_parse_crypt_hdr() sign_as behavior. X-Git-Tag: neomutt-20160307~89 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b21dc3a197a774036c59ab91bca20b6fb139cb6e;p=neomutt 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 index 801ef1042..f61297315 100644 --- a/postpone.c +++ b/postpone.c @@ -409,7 +409,7 @@ int mutt_get_postponed (CONTEXT *ctx, HEADER *hdr, HEADER **cur, char *fcc, size -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; @@ -511,11 +511,13 @@ int mutt_parse_crypt_hdr (const char *p, int set_signas, int crypt_app) /* 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;