deltachat / deltachat-core-rust

Delta Chat Rust Core library, used by Android/iOS/desktop apps, bindings and bots 📧
https://delta.chat/en/contribute
Other
669 stars 85 forks source link

No HTML if multiple text parts are cut #4462

Open link2xt opened 1 year ago

link2xt commented 1 year ago

I have received an email which consists of a short text/plain part, long inline message/rfc822 (forwarded mail) and a text/plain attachment.

The second part is cut, but "Show Full Message..." is displayed under the first part and displays the same short message I can already see. The second part I can only fully read in the message info.

link2xt commented 1 year ago

The problem starts with a mimeparser, which stores is_mime_modified for the whole message rather than a part: https://github.com/deltachat/deltachat-core-rust/blob/4767f1ce743d2170142c3cc126838d55505eb807/src/mimeparser.rs#L103 Whether to display "Show Full Message..." should be decided per part, not for all parts at once. In extreme case it should be possible to receive an email consisting of 3 multipart/alternative parts, each of which contains a text and HTML subpart in turn. In this case receive_imf should add 3 message bubbles, each with a "Show Full Message..." link. This also means that decoded_data should be per-part, not a single one for the whole message, so each message bubble can have a different "full message": https://github.com/deltachat/deltachat-core-rust/blob/4767f1ce743d2170142c3cc126838d55505eb807/src/receive_imf.rs#L1077 Before, mime_headers column was always storing the whole decrypted message, but now it should be able to store message parts which contain the relevant HTML part.

iequidoo commented 3 weeks ago

So this mostly looks like a refactoring, i can try to implement this, but if there are possible problems, let me know

iequidoo commented 5 days ago

I tried to forward a long message using Thunderbird to Delta Chat, adding also a long text and an attachment, but i see only one message bubble with the attachment, with the correctly truncated text, and if i press on Show Full Message..., i see the full text and the forwarded message. So, i can't reproduce it with Thunderbird, seems it never creates messages with multiple multipart/alternative parts. @link2xt, do you have an example message? I can try to form such a message manually, just interesting where such messages come from

link2xt commented 5 days ago

I found the mail, it seems to be produced by mutt.

There are actually two parts, first is text/plain and second is message/rfc822. message/rfc822 is a forwarded mail consisting of text/plain text part and a text/plain attachment.

Here is how decrypted part looks like:

Content-Type: multipart/mixed; boundary="zRs3OquGy6eU58KF"

--zRs3OquGy6eU58KF
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hello!

Best regards,
Alice

--zRs3OquGy6eU58KF
Content-Type: message/rfc822
Content-Disposition: inline

From: AAA <aaa@example.org>
To: Alice <alice@example.org>
Subject: Some subject
Date: Fri, 2 Jun 2023 12:29:17 +0000
Message-ID: <foobar@localhost>
In-Reply-To: <barbaz@localhost>
Content-Type: multipart/mixed;
    boundary="_innerboundary_"
MIME-Version: 1.0

--_innerboundary_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hi
Hi
Hi
Tons of text here
Tons of text
...

--=20

Kind regards,

Bob

--_innerboundary_
Content-Type: text/plain; name="deltachat-log.txt"
Content-Description: deltachat-log.txt
Content-Disposition: attachment; filename="deltachat-log.txt";
    size=55254; creation-date="Fri, 02 Jun 2023 11:33:49 GMT";
    modification-date="Fri, 02 Jun 2023 12:29:17 GMT"

Huge huge Delta Chat log here.

--_innerboundary_--

--zRs3OquGy6eU58KF--