Bug 419978

Summary: KMail missing line break in blockquote when showing as HTML mail
Product: [Applications] kdepim Reporter: null <null>
Component: messageviewerAssignee: kdepim bugs <kdepim-bugs>
Status: REOPENED ---    
Severity: normal CC: casta+kde, montel
Priority: NOR    
Version: GIT (master)   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 5.18.3
Sentry Crash Report:
Attachments: Test Case
KMail 5.14.40 vs. Thunderbird 68.6.

Description null 2020-04-12 06:56:55 UTC
Created attachment 127459 [details]
Test Case

See attached test case: With HTML mode enabled, the quoted reply (wrapped in <blockquote>) is missing the line break between "HTML QUOTE" and "SECOND LINE".

This works correctly in Thunderbird (see screenshot).

(The reply not showing up was already fixed in Bug 419949.)

I can reproduce this bug with KMail 5.9.2 (Qt 5.11.2 / KF 5.51) as well as KMail 5.14.40 (Qt 5.14.1 / KF 5.69).
Comment 1 null 2020-04-12 06:57:34 UTC
Created attachment 127460 [details]
KMail 5.14.40 vs. Thunderbird 68.6.
Comment 2 Laurent Montel 2020-04-12 09:25:08 UTC
I confirm it
Comment 3 Laurent Montel 2021-10-13 06:12:03 UTC
Git commit 6cc49743f3f9521e3a0f75083d9fd6c01e019250 by Laurent Montel.
Committed on 13/10/2021 at 06:11.
Pushed by mlaurent into branch 'release/21.08'.

Fix Bug 419978 - KMail missing line break in blockquote when showing as HTML mail

FIXED-IN: 5.18.3

M  +2    -1    templateparser/src/templateparserjob.cpp

https://invent.kde.org/pim/messagelib/commit/6cc49743f3f9521e3a0f75083d9fd6c01e019250
Comment 4 null 2021-10-14 06:58:54 UTC
Thanks, but I'm afraid this does not fix the bug for me. I tested a build of messagelib master based on eead28d3, where the quoted HTML text still displayed as

"a b"

instead of what it should look like:

"a
b"

Are you sure you have tested the attached test case in HTML mode (in plaintext mode it was already working before) and looked at the quoted text at the bottom? Or perhaps the commit did not include all changes necessary?
Comment 5 Laurent Montel 2021-10-14 08:08:44 UTC
code from your email:
"
<div>You wrote:<blockquote style="margin: 0.8ex 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">HTML QUOTE

SECOND LINE
</blockquote></div>
"
create a t.html put these line into.
Open it with firefox
you can see that there is a bug.
So indeed a broken generated code will provide a bad rendering.
I can't fix a bug in existing email.
I can fix when I generate html code (already done)
Comment 6 null 2021-10-14 08:34:23 UTC
I agree the code generated by some mail apps (GMX app in particular) is often problematic, sadly some senders insist on using them. However, it leads to KMail displaying the whole multi-paragraph quote without any linebreaks whatsoever, which is not what was intended by the sender and which is very hard to read.

As you can see from the screenshot, Thunderbird is able to display the mail just fine. I just retested with Thunderbird 91.2, it still works there. If "t.html" does not work in Firefox, it means Thunderbird (which also uses the Gecko engine) might have added a workaround, e.g. transforming "blockquote" to "pre" (while making sure to copy over other styling such as the use of a non-monospace font).

It would be great if KMail was able to reach the same level of compatibility, even for "broken" mails.
Comment 7 Laurent Montel 2021-10-14 13:33:18 UTC
(In reply to null from comment #6)
> I agree the code generated by some mail apps (GMX app in particular) is
> often problematic, sadly some senders insist on using them. However, it
> leads to KMail displaying the whole multi-paragraph quote without any
> linebreaks whatsoever, which is not what was intended by the sender and
> which is very hard to read.
> 
> As you can see from the screenshot, Thunderbird is able to display the mail
> just fine. I just retested with Thunderbird 91.2, it still works there. If
> "t.html" does not work in Firefox, it means Thunderbird (which also uses the
> Gecko engine) might have added a workaround, e.g. transforming "blockquote"
> to "pre" (while making sure to copy over other styling such as the use of a
> non-monospace font).
> 
> It would be great if KMail was able to reach the same level of
> compatibility, even for "broken" mails.

If thunderbird has a workaround about it it's directly in gecko engine, if I want to make a workaround I need to parse html text before displaying it, it will need a lot of regexp which increase time to display message.
It's very not good as I need to do it for each message...
Comment 8 null 2021-10-14 14:22:28 UTC
I thought KMail was already sanitizing messages somewhat for Qt to consume anyway, so the performance impact would be negligible.

If that is not the case and this would impact performance for the majority of cases too much, feel free to close the bug as WONTFIX or keep it open in case someone else has a good idea for a better fix. I'm fine with both, as long as we do not pretend the issue is FIXED already.

I will have to investigate piping incoming mail through a filter to replace linebreaks in blockquotes from that sender with "<br>" (obviously modifying incoming mail is a no-go to include in upstream KMail).

Thanks anyway for your help so far.