the-djmaze / snappymail

Simple, modern & fast web-based email client
https://snappymail.eu
GNU Affero General Public License v3.0
978 stars 114 forks source link

Blank email displayed when "Prefer HTML to plain text" is unchecked and the message is html only #1302

Closed apezio closed 9 months ago

apezio commented 10 months ago

When "Prefer HTML to plain text" is unchecked, and the message being viewed is HTML only, no message is displayed.

I would expect there to be logic that would show the HTML message if there is no plain text.

To reproduce:

Uncheck "Prefer HTML to plain text" in Settings. Go to any mailbox and view an html-only message. it will be blank. The "View HTML Message" option on the hamburger dropdown will correctly show the message.

NOTE:

Once "View HTML Message" option is selected - upon returning to plain text view there is a stripped down version of the HTML message displayed.

Latest git source. Dovecot Safari, Opera, Google Chrome. standalone mode.

apezio commented 10 months ago

Screenshot 1: Message first viewed (prefer plaintext over html option enabled in Settings). screenshot1

Screenshot 2: "View HTML Message" screenshot2

Screenshot 3: "View plain text Message" screenshot3

the-djmaze commented 9 months ago

When you look at the source of the email, you will notice that there is an empty Content-Type: text/plain part in there.

This means the sender screwed up the sending of their emails. You should report to them.

apezio commented 9 months ago

Nope. I checked 10 emails with this issue (about 1/4 of the email I receive has this issue) and none have Content-Type: text/plain.

Edit: the error below is from a browser extension: "DarkReader". Disabling it has no effect on the Snappymail issue.

I do see this error in Safari's JavaScript Console: Refused to execute a script because its hash or 'unsafe-inline' does not appear in the script-src directive of the Content Security Policy

Maybe they are related? (Edit: Nope)

apezio commented 9 months ago

Example email would be something simple like this:

<headers here>

<!DOCTYPE html> <html here> </body> </html>=

apezio commented 9 months ago

Happens in Safari 14.1.2 and Opera 97.0.4719.63. I don't feel like it's a browser thing.

in class bodyText there are 5 different text-part plain's, 4 are hidden and one is shown.

The hidden ones seems to be the bodies of other emails, while this one is for the current email:

<div id="rl-msg-0ae22688dee4e88e49646957b8bf67f1" class="b-text-part plain"></div>

apezio commented 9 months ago

This happens with every HTML-only email, unfortunately it's not the sender(s) email format. :)

the-djmaze commented 9 months ago

To properly understand the issue, we need to investigate the source of the emails.

For example, here's a multipart with html and plain:

Content-Type: multipart/alternative; 
    boundary="----=_Part_113431976_1099401662.1699967195390"

------=_Part_113431976_1099401662.1699967195390
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hey=20
there,

------=_Part_113431976_1099401662.1699967195390
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.=
w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

For example, here's an html only:

Content-Type: text/html; charset="UTF-8"

<html dir=3D"ltr" lang=3D"en">=0A=0A  <head>=0A    <meta http-equiv=3D"Cont=

SnappyMail should show these properly and have a toggle button. If the body of the converted html to plain is empty, we need to figure out why your browser fails.

apezio commented 9 months ago

Once I select "view as plain text" in the hamburger menu, the converted message shows.

But before that, the body is blank. (When Prefer Plain text is set in settings)

I will upload a few email sources if you want to see.

emails.zip

apezio commented 9 months ago

Tried Chrome 110.0.5481.100. Same issue.

apezio commented 9 months ago

Thanks, that fixed it!