From: Kevin McCarthy Date: Fri, 25 Jan 2019 02:28:27 +0000 (-0800) Subject: Show top-level decoded smime text/plain parts. X-Git-Tag: mutt-1-11-3-rel~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1041fb4ff812bf96548c8f6c7d631954b1279222;p=mutt Show top-level decoded smime text/plain parts. Commit 331d9d5a attempted to fix a problem with an attachment having extension .p7m. The attachment menu tried to decode and failed, and the part ended up being replaced by a bogus text/plain part. The problem is that crypt_smime_decrypt_mime() returns a text/plain part if the decode fails, meaning we can't distinguish failure from success in this case. As a compromise, only use a text/plain resulting from a single top-level application_smime part. This will allow for the case of an text/plain encoded email, but won't end up hiding attachments that were not decoded. --- diff --git a/recvattach.c b/recvattach.c index 1bd4b48e..b4c77676 100644 --- a/recvattach.c +++ b/recvattach.c @@ -926,18 +926,19 @@ mutt_attach_display_loop (MUTTMENU *menu, int op, HEADER *hdr, static void mutt_generate_recvattach_list (ATTACH_CONTEXT *actx, HEADER *hdr, - BODY *m, + BODY *parts, FILE *fp, int parent_type, int level, int decrypted) { ATTACHPTR *new; + BODY *m; BODY *new_body = NULL; FILE *new_fp = NULL; int type, need_secured, secured; - for (; m; m = m->next) + for (m = parts; m; m = m->next) { need_secured = secured = 0; @@ -957,11 +958,14 @@ static void mutt_generate_recvattach_list (ATTACH_CONTEXT *actx, secured = !crypt_smime_decrypt_mime (fp, &new_fp, m, &new_body); /* If the decrypt/verify-opaque doesn't generate mime output, an - * empty "TEXT" type will still be returned by - * mutt_read_mime_header(). Since recursing over that type - * isn't interesting and loses information about the original - * attachment, just abort and view normally. */ - if (secured && new_body->type == TYPETEXT) + * empty text/plain type will still be returned by + * mutt_read_mime_header(). We can't distinguish an actual part + * from a failure, so only use a text/plain that results from a single + * top-level part. */ + if (secured && + new_body->type == TYPETEXT && + !ascii_strcasecmp ("plain", new_body->subtype) && + (parts != m || m->next)) { mutt_free_body (&new_body); safe_fclose (&new_fp);