X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=postpone.c;h=0e85fe09759446cf3e4348f84c9b3eb327f3bf3b;hp=449f83e8aa355c039a7115c9576cafaa540a392e;hb=3d937534e7b1ee723f86594b5e4c64c95158a933;hpb=6833ce8bdca2d64e14485118f2a4417b7e1cb1b1 diff --git a/postpone.c b/postpone.c index 449f83e..0e85fe0 100644 --- a/postpone.c +++ b/postpone.c @@ -498,6 +498,11 @@ int mutt_parse_crypt_hdr (char *p, int set_signas) *q = '\0'; break; + case 'i': + case 'I': + pgp |= INLINE; + break; + default: mutt_error _("Illegal PGP header"); return 0; @@ -549,17 +554,19 @@ int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr, FREE (&newhdr->env->mail_followup_to); /* really? */ /* decrypt pgp/mime encoded messages */ - /* XXX - what happens with S/MIME encrypted messages?!?!? - tlr, 020909*/ - if ((WithCrypto & APPLICATION_PGP) - && (hdr->security & APPLICATION_PGP) + + if ((WithCrypto & (APPLICATION_PGP|APPLICATION_SMIME) & hdr->security) && mutt_is_multipart_encrypted (newhdr->content)) { - newhdr->security |= PGPENCRYPT; - if (!crypt_valid_passphrase(APPLICATION_PGP)) + int ccap = WithCrypto & (APPLICATION_PGP|APPLICATION_SMIME) & hdr->security; + newhdr->security |= ENCRYPT | ccap; + if (!crypt_valid_passphrase (ccap)) goto err; - mutt_message _("Invoking PGP..."); - if (crypt_pgp_decrypt_mime (fp, &bfp, newhdr->content, &b) == -1 || b == NULL) + mutt_message _("Decrypting message..."); + if (((ccap & APPLICATION_PGP) && crypt_pgp_decrypt_mime (fp, &bfp, newhdr->content, &b) == -1) + || ((ccap & APPLICATION_SMIME) && crypt_smime_decrypt_mime (fp, &bfp, newhdr->content, &b) == -1) + || b == NULL) { err: mx_close_message (&msg); @@ -594,6 +601,7 @@ int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr, newhdr->content = mutt_remove_multipart (newhdr->content); } + /* * We don't need no primary multipart. * Note: We _do_ preserve messages! @@ -651,7 +659,20 @@ int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr, goto bail; - mutt_decode_attachment (b, &s); + if ((WithCrypto & APPLICATION_PGP) + && (mutt_is_application_pgp (b) & (ENCRYPT|SIGN))) + { + + mutt_body_handler (b, &s); + + newhdr->security |= mutt_is_application_pgp (newhdr->content); + + b->type = TYPETEXT; + mutt_str_replace (&b->subtype, "plain"); + mutt_delete_parameter ("x-action", &b->parameter); + } + else + mutt_decode_attachment (b, &s); if (safe_fclose (&s.fpout) != 0) goto bail; @@ -665,6 +686,24 @@ int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr, if (b->hdr) b->hdr->content = NULL; /* avoid dangling pointer */ } + /* Fix encryption flags. */ + + /* No inline if multipart. */ + if (WithCrypto && (newhdr->security & INLINE) && newhdr->content->next) + newhdr->security &= ~INLINE; + + /* Do we even support multiple mechanisms? */ + newhdr->security &= WithCrypto | ~(APPLICATION_PGP|APPLICATION_SMIME); + + /* Theoretically, both could be set. Take the one the user wants to set by default. */ + if ((newhdr->security & APPLICATION_PGP) && (newhdr->security & APPLICATION_SMIME)) + { + if (option (OPTSMIMEISDEFAULT)) + newhdr->security &= ~APPLICATION_PGP; + else + newhdr->security &= ~APPLICATION_SMIME; + } + rv = 0; bail: