changeset: 6414:3f4dc0ce66ae user: Kevin McCarthy <[email protected]> date: Mon Feb 02 13:25:17 2015 -0800 link: http://dev.mutt.org/hg/mutt/rev/3f4dc0ce66ae
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". changeset: 6415:d2f5832a9e68 user: Kevin McCarthy <[email protected]> date: Wed Feb 04 11:04:08 2015 -0800 link: http://dev.mutt.org/hg/mutt/rev/d2f5832a9e68 Protect SmimeDefaultKey for postpone/resume. PgpSignAs is saved and restored in ci_send_message(), but SmimeDefaultKey was not. Also, fix a bug where an empty PgpSignAs was not restored back to empty if the postponed email contained a SignAs value. diffs (80 lines): diff -r 1235dd48ef3f -r d2f5832a9e68 postpone.c --- a/postpone.c Sat Jan 31 20:05:30 2015 -0800 +++ b/postpone.c Wed Feb 04 11:04:08 2015 -0800 @@ -409,7 +409,7 @@ -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 @@ /* 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; diff -r 1235dd48ef3f -r d2f5832a9e68 send.c --- a/send.c Sat Jan 31 20:05:30 2015 -0800 +++ b/send.c Wed Feb 04 11:04:08 2015 -0800 @@ -1130,8 +1130,9 @@ BODY *save_content = NULL; BODY *clear_content = NULL; char *pgpkeylist = NULL; - /* save current value of "pgp_sign_as" */ - char *signas = NULL; + /* save current value of "pgp_sign_as" and "smime_default_key" */ + char *pgp_signas = NULL; + char *smime_default_key = NULL; char *tag = NULL, *err = NULL; char *ctype; @@ -1151,8 +1152,13 @@ } - if ((WithCrypto & APPLICATION_PGP) && (flags & SENDPOSTPONED)) - signas = safe_strdup(PgpSignAs); + if (flags & SENDPOSTPONED) + { + if (WithCrypto & APPLICATION_PGP) + pgp_signas = safe_strdup(PgpSignAs); + if (WithCrypto & APPLICATION_SMIME) + smime_default_key = safe_strdup(SmimeDefaultKey); + } /* Delay expansion of aliases until absolutely necessary--shouldn't * be necessary unless we are prompting the user or about to execute a @@ -1867,12 +1873,17 @@ cleanup: - if ((WithCrypto & APPLICATION_PGP) && (flags & SENDPOSTPONED)) + if (flags & SENDPOSTPONED) { - if(signas) + if (WithCrypto & APPLICATION_PGP) { FREE (&PgpSignAs); - PgpSignAs = signas; + PgpSignAs = pgp_signas; + } + if (WithCrypto & APPLICATION_SMIME) + { + FREE (&SmimeDefaultKey); + SmimeDefaultKey = smime_default_key; } }
