Bug 368060 - Replying to html email that has a PDF attachment creates junk in the reply
Summary: Replying to html email that has a PDF attachment creates junk in the reply
Status: RESOLVED FIXED
Alias: None
Product: kmail2
Classification: Applications
Component: composer (show other bugs)
Version: 5.3.1
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
: 368692 369245 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-08-31 15:20 UTC by Ian
Modified: 2016-10-26 21:36 UTC (History)
8 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.3.4


Attachments
Example mbox showing problem. (859 bytes, application/mbox)
2016-10-24 22:49 UTC, Simon Levitt
Details
Code hack (704 bytes, patch)
2016-10-25 21:07 UTC, Simon Levitt
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ian 2016-08-31 15:20:06 UTC
Received an email that is in HTML and had a PDF attached.  I pressed reply, and it took a while to create the reply window that eventually contained the original text plus a whole load of garbage which i assume is a dump of the PDF attachment

Reproducible: Always

Steps to Reproduce:
1. Reply to html email with PDF attached (make sure "Prefer HTML to plain text" is NOT set
2.
3.

Actual Results:  
creates a reply window containing the original text plus a whole load of garbage which i assume is a dump of the PDF attachment

Expected Results:  
Create a reply window only containing the original text
Comment 1 Stephan Diestelhorst 2016-09-20 14:57:03 UTC
Got the same with a PNG attached.  Current workaround: mark the text you are replying to and then reply -> will only copy out the text of the reply.
Comment 2 Ian 2016-09-26 10:04:02 UTC
closing account so closing bugs
Comment 3 Stephan Diestelhorst 2016-09-26 10:24:49 UTC
Erm... no?  This is still a bug and you closing your account does not make the bug disappear.  I'll just rereport the same thing. :-S
Comment 4 Stephan Diestelhorst 2016-09-26 10:25:13 UTC
What I am saying is: please reopen; thanks!
Comment 5 Johannes Studt 2016-09-27 07:46:01 UTC
Can confirm this.

Kmail 16.08.1 on Opensuse Tumbleweed.
Comment 6 Christian Saemann 2016-10-04 09:10:57 UTC
Can confirm this bug with png attachments as well as the workaround from comment 1, on Kmail 5.3.0, latest packages from opensuse Tumbleweed. This is a rather annoying bug in everyday use of kmail. I'm happy to test/provide more details if this is helpful. It seems that it doesn't recognize the mime type of the attachment. It simply quotes the binary content of the attachment, and produces many lines as e.g.:

> ÷$÷É_]±ÓN"2Î<ðDÀ?Âwr:½®*Tá©Äoù¶ü|_
Comment 7 Simon Levitt 2016-10-24 22:49:29 UTC
Created attachment 101760 [details]
Example mbox showing problem.

I'm also seeing this, specifically for HTML only emails (ie. no text/plain part in the mail) with embedded images.
The attached file is a simple email that shows the problem with a multipart/related - On hitting reply the quoted text is 'Image1' which is the data for the first attached image, not the expected 'HTML Text'.
Comment 8 Simon Levitt 2016-10-25 21:07:08 UTC
Created attachment 101783 [details]
Code hack

After some more digging around, I discovered that toplevelTextNode() in utils.cpp is returning non-text parts.

That is because AttachmentMessagePart extends TextMessagePart, and therefore it's been deeming images/etc. as textual.

The attached patch hacks a quick fix to not return an AttachmentMessagePart which seems to work around the problem and makes replies work as expected for me.
Comment 9 Sandro Knauß 2016-10-26 14:33:28 UTC
Can reproduce with 16.08
Comment 10 Sandro Knauß 2016-10-26 14:35:30 UTC
*** Bug 369245 has been marked as a duplicate of this bug. ***
Comment 11 Sandro Knauß 2016-10-26 14:37:18 UTC
*** Bug 368692 has been marked as a duplicate of this bug. ***
Comment 12 Sandro Knauß 2016-10-26 15:42:04 UTC
Git commit bf247fc9e802a39b60c8828019401569f6ad99fa by Sandro Knauß.
Committed on 26/10/2016 at 15:41.
Pushed by knauss into branch 'Applications/16.08'.

Fix: Attachments are included as plain text in replied mails

Thanks to Simon Levitt to point to the corrent part that needs to be
fixed.
FIXED-IN: 5.3.4

M  +2    -1    mimetreeparser/src/bodyformatter/utils.cpp

http://commits.kde.org/messagelib/bf247fc9e802a39b60c8828019401569f6ad99fa
Comment 13 Simon Levitt 2016-10-26 16:51:16 UTC
Is my 'hack', really the correct fix?
Why are AttachmentMessagePart objects deemed textual?, that seems wrong to me.
Comment 14 Till Schäfer 2016-10-26 17:48:52 UTC
Hmm, it seems fine to not include text attachments either, but there seems to something else broken, as a rar attachment (see Bug 369245) is definitely no text.
Comment 15 Sandro Knauß 2016-10-26 21:36:23 UTC
The current class hierarchy has nothing to do with representation of a specific  "mime"-type. And in this hierarchy AttachmentPart is a subclass of TextPart, because AttachmentPart has every property of a TextPart.
That's why isTextPart is true for every attachment.