]> granicus.if.org Git - neomutt/commitdiff
Handle improperly encoded pgp/mime octetstream part
authorKevin McCarthy <kevin@8t8.us>
Fri, 21 Dec 2018 18:13:17 +0000 (10:13 -0800)
committerRichard Russon <rich@flatcap.org>
Mon, 7 Jan 2019 15:09:41 +0000 (15:09 +0000)
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.

Co-authored-by: Richard Russon <rich@flatcap.org>
handler.c
ncrypt/crypt_gpgme.c
ncrypt/pgp.c

index 7caee9071bc301d812c8e7ec66edb81ea61ed70a..bc3c86383e4a076c03cbc85f733e18f11780163c 100644 (file)
--- a/handler.c
+++ b/handler.c
@@ -1414,7 +1414,12 @@ static int valid_pgp_encrypted_handler(struct Body *b, struct State *s)
   mutt_env_free(&b->mime_headers);
   mutt_env_free(&octetstream->mime_headers);
 
-  int rc = crypt_pgp_encrypted_handler(octetstream, s);
+  int rc;
+  /* Some clients improperly encode the octetstream part. */
+  if (octetstream->encoding != ENC_7BIT)
+    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 */
index e42abe878e47e5a84601687e392921ce84356377..da4ac20dfc80d05226e4cb8caaa174b419ec6154 100644 (file)
@@ -2212,7 +2212,12 @@ int pgp_gpgme_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Body
   first_part->warnsig = false;
 
   if (mutt_is_valid_multipart_pgp_encrypted(b))
+  {
     b = b->parts->next;
+    /* Some clients improperly encode the octetstream part. */
+    if (b->encoding != ENC_7BIT)
+      need_decode = true;
+  }
   else if (mutt_is_malformed_multipart_pgp_encrypted(b))
   {
     b = b->parts->next->next;
@@ -3153,7 +3158,6 @@ int smime_gpgme_application_handler(struct Body *a, struct State *s)
 
   /* clear out any mime headers before the handler, so they can't be spoofed. */
   mutt_env_free(&a->mime_headers);
-
   a->warnsig = false;
   FILE *fpout = mutt_file_mkstemp();
   if (!fpout)
index 2db68ecf1efe3a6b21fe0dcbceb7cb43b2c10344..f3423ad34e7c63a6b23bfe523c14b08fd2087d02 100644 (file)
@@ -1131,7 +1131,12 @@ int pgp_class_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Body
   int rc = 0;
 
   if (mutt_is_valid_multipart_pgp_encrypted(b))
+  {
     b = b->parts->next;
+    /* Some clients improperly encode the octetstream part. */
+    if (b->encoding != ENC_7BIT)
+      need_decode = true;
+  }
   else if (mutt_is_malformed_multipart_pgp_encrypted(b))
   {
     b = b->parts->next->next;