From: Kevin McCarthy Date: Fri, 21 Dec 2018 18:13:17 +0000 (-0800) Subject: Handle improperly encoded pgp/mime octetstream part. X-Git-Tag: mutt-1-12-rel~168 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=450de4637f6590487a073b250da342a1400a3ac3;p=mutt Handle improperly encoded pgp/mime octetstream part. Some clients (or even mail servers) improperly encode the octetstream part. Thanks to Riccardo Schirone for the original merge request patch. This commit also handles the attachment menu, and makes the decoding conditional so it's not done if it isn't necessary. --- diff --git a/crypt-gpgme.c b/crypt-gpgme.c index d1cd407e..cb2f248b 100644 --- a/crypt-gpgme.c +++ b/crypt-gpgme.c @@ -2038,7 +2038,12 @@ int pgp_gpgme_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur) first_part->warnsig = 0; if (mutt_is_valid_multipart_pgp_encrypted (b)) + { b = b->parts->next; + /* Some clients improperly encode the octetstream part. */ + if (b->encoding != ENC7BIT) + need_decode = 1; + } else if (mutt_is_malformed_multipart_pgp_encrypted (b)) { b = b->parts->next->next; diff --git a/handler.c b/handler.c index ebcd384f..92ce1867 100644 --- a/handler.c +++ b/handler.c @@ -1701,7 +1701,11 @@ static int valid_pgp_encrypted_handler (BODY *b, STATE *s) mutt_free_envelope (&b->mime_headers); mutt_free_envelope (&octetstream->mime_headers); - rc = crypt_pgp_encrypted_handler (octetstream, s); + /* Some clients improperly encode the octetstream part. */ + if (octetstream->encoding != ENC7BIT) + rc = run_decode_and_handler (octetstream, s, crypt_pgp_encrypted_handler, 0); + else + rc = crypt_pgp_encrypted_handler (octetstream, s); b->goodsig |= octetstream->goodsig; /* Relocate protected headers onto the multipart/encrypted part */ diff --git a/pgp.c b/pgp.c index f3ee034f..6224fc32 100644 --- a/pgp.c +++ b/pgp.c @@ -1044,7 +1044,12 @@ int pgp_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur) int rv = 0; if (mutt_is_valid_multipart_pgp_encrypted (b)) + { b = b->parts->next; + /* Some clients improperly encode the octetstream part. */ + if (b->encoding != ENC7BIT) + need_decode = 1; + } else if (mutt_is_malformed_multipart_pgp_encrypted (b)) { b = b->parts->next->next;