Multipart / Attachment handling overview
@kesselb is already working on this.
Since Jul 24, 2023.
- Dominant language
- JavaScript
- Stars
- 1k
- Forks
- 348
- Avg merge
- 12h 28m
- Merged PRs (30d)
- 91
Description
The purpose of this issue is to document known issues with our multipart and attachment handling.
Hidden attachments
Original report https://github.com/nextcloud/mail/issues/5282 and partly fixed by https://github.com/nextcloud/mail/pull/5339.
Sample eml
Return-Path: <alice@test.local>
Delivered-To: jane@doe.local
Received: from fcf416df7902
by fcf416df7902 with LMTP
id oKwwBSNDuWSRAQAAuSYRyA
(envelope-from <alice@test.local>)
for <jane@doe.local>; Thu, 20 Jul 2023 14:22:27 +0000
Received: from localhost (unknown [172.19.0.1])
by fcf416df7902 (Postfix) with ESMTP id 063732260B32
for <jane@doe.local>; Thu, 20 Jul 2023 14:22:27 +0000 (UTC)
From: alice@test.local
To: jane@doe.local
Subject: Patches
Message-ID: <20230720162227.Horde.tQbO75MfhHKIerc-38l3V5j@pc>
User-Agent: Horde Application Framework 5
Date: Thu, 20 Jul 2023 16:22:27 +0200
Content-Type: multipart/mixed; boundary="=_ltOS0Zz8DtIKjXr3jbdMGDN"
MIME-Version: 1.0
This message is in MIME format.
--=_ltOS0Zz8DtIKjXr3jbdMGDN
Content-Type: multipart/alternative; boundary="=_sVhlJCYnkclzOHfh6XZ-w5L"
This message is in MIME format.
--=_sVhlJCYnkclzOHfh6XZ-w5L
Content-Type: text/html; charset=utf-8
Content-Description: HTML Version of Message
<html><meta http-equiv="content-type" content="text/html; charset=UTF-8"><body>Hello Hello</body><html>
--=_sVhlJCYnkclzOHfh6XZ-w5L
Content-Type: text/plain; charset=utf-8
Content-Description: Plaintext Version of Message
Hello Hello
--=_sVhlJCYnkclzOHfh6XZ-w5L--
--=_ltOS0Zz8DtIKjXr3jbdMGDN
Content-Type: text/x-patch; name=some.patch
Content-Disposition: inline; filename=some.patch
hello world
--=_ltOS0Zz8DtIKjXr3jbdMGDN--
Generated via: https://github.com/kesselb/weird-emails/blob/main/attachment_content_disposition_inline.php
Message structure
graph TD;
multipart/mixed-->multipart/alternative;
multipart/alternative-->text/html;
multipart/alternative-->text/plain;
multipart/mixed-->text/x-patch;
Screenshots
Thunderbird
HTML message
Content-Disposition for text/x-patch is inline
Issue: We assume that mime parts with content-disposition = inline are referenced in via content-id / cid in the html document. Is the mime part not referenced, it's hidden.
Possible solutions:
- Merge inlineAttachments and attachments like for text/plain emails.
- If content-disposition = inline && content-id = null, then treat mime part as regular attachment.
Hidden message
Sample eml
Return-Path: <alice@test.local>
Delivered-To: jane@doe.local
Received: from fcf416df7902
by fcf416df7902 with LMTP
id lko6KsJTuWQUBAAAuSYRyA
(envelope-from <alice@test.local>)
for <jane@doe.local>; Thu, 20 Jul 2023 15:33:22 +0000
Received: from localhost (unknown [172.19.0.1])
by fcf416df7902 (Postfix) with ESMTP id 9BEA52260B32
for <jane@doe.local>; Thu, 20 Jul 2023 15:33:22 +0000 (UTC)
From: alice@test.local
To: jane@doe.local
Subject: Multipart with multiple parts
Message-ID: <20230720173322.Horde.Lbu6mga1p0l6Yh4ZFm-Exh4@pc>
User-Agent: Horde Application Framework 5
Date: Thu, 20 Jul 2023 17:33:22 +0200
Content-Type: multipart/mixed; boundary="=_Xs2dih_sEN07PRgH-bx7MWq"
MIME-Version: 1.0
This message is in MIME format.
--=_Xs2dih_sEN07PRgH-bx7MWq
Content-Type: text/html; charset=utf-8
Content-Description: HTML Version of Message
<html><meta http-equiv="content-type" content="text/html; charset=UTF-8"><body>Hello Hello</body><html>
--=_Xs2dih_sEN07PRgH-bx7MWq
Content-Type: text/html; charset=utf-8
Content-Description: HTML Version of Message
<html><meta http-equiv="content-type" content="text/html; charset=UTF-8"><body>Hope you are dooing fine</body><html>
--=_Xs2dih_sEN07PRgH-bx7MWq--
Generated via: https://github.com/kesselb/weird-emails/blob/main/multipart_with_multiple_parts.php
Message structure
graph TD;
multipart/mixed-->text/html;
multipart/mixed-->text/html;
Screenshots
Thunderbird
Multipart message with multiple text/html parts.
Issue: We show the first text/html part. Without looking at the source, you don't know there's something else.
Possible solutions:
- Render both text/html parts
- Add the mime parts as attachment
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.