/**
* mutt_generate_recvattach_list - Create a list of attachments
* @param actx Attachment context
- * @param e Email
- * @param m Body of email
+ * @param e Email
+ * @param parts Body of email
* @param fp File to read from
* @param parent_type Type, e.g. #TYPE_MULTIPART
* @param level Attachment depth
* @param decrypted True if attachment has been decrypted
*/
static void mutt_generate_recvattach_list(struct AttachCtx *actx, struct Email *e,
- struct Body *m, FILE *fp, int parent_type,
- int level, bool decrypted)
+ struct Body *parts, FILE *fp,
+ int parent_type, int level, bool decrypted)
{
struct AttachPtr *new = NULL;
+ struct Body *m = NULL;
struct 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 = 0;
secured = 0;
}
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 == TYPE_TEXT)
+ /* If the decrypt/verify-opaque doesn't generate mime output, an 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 == TYPE_TEXT) &&
+ (mutt_str_strcasecmp("plain", new_body->subtype) == 0) &&
+ ((parts != m) || m->next))
{
mutt_body_free(&new_body);
mutt_file_fclose(&new_fp);