Bug 368692 - kMail 5.3.x: Wrong MIME part selected as Reply text
Summary: kMail 5.3.x: Wrong MIME part selected as Reply text
Status: RESOLVED DUPLICATE of bug 368060
Alias: None
Product: kmail2
Classification: Applications
Component: composer (show other bugs)
Version: unspecified
Platform: Neon Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-12 13:05 UTC by Gunter Ohrner
Modified: 2016-10-26 14:37 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Demo message, if you reply to this message, the wrong MIME part is selected as the body text. (4.16 KB, message/rfc822)
2016-09-12 13:06 UTC, Gunter Ohrner
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gunter Ohrner 2016-09-12 13:05:58 UTC
See the attached test message which is modelled after a message I received today.

My kMail is configured to compose plain text messages.

If I reply to this message, the last attachment (a PDF tagged as "application/octet-stream") is taken as the body text and quoted in the composer.

For the original message, this attachment was 9 MB in size, freezing kMail for quite some time until the composer opened with lots of garbage (binary PDF stuff) inside.

Expected behaviour: The text body should be converted to plain text and used as the reply template, not the binary PDF attachment.

Reproducible: Always
Comment 1 Gunter Ohrner 2016-09-12 13:06:39 UTC
Created attachment 101055 [details]
Demo message, if you reply to this message, the wrong MIME part is selected as the body text.
Comment 2 Gunter Ohrner 2016-09-12 13:28:50 UTC
Addendum: This bug makes it hard to even reply to such mails.

A workaround is to select the text part before hitting reply, kMail will then correctly quote and insert the selected text into composer.

If you do not know (or do not remember) this feature, you'll be stuck and kMail might be as well, if the misused attachment is only big enough... ;)
Comment 3 Gunter Ohrner 2016-09-21 13:15:00 UTC
This happens with several mails I received and is pretty annoying... First you hit reply, then kMail freezes eating 100% CPU and you just think "Oh no, not again...", then the editor opens showing you a "quoted PDF" and you have to close the editor, select the text you want to reply to and hit "reply" again - hmpf...

Copy pasted from my Composer window:

Am Dienstag, 20. September 2016, 20:59:20 CEST schrieben Sie:
> %PDF-1.5
> %µµµµ
> 1 0 obj
> <</Type/Catalog/Pages 2 0 R/Lang(de-DE) /StructTreeRoot 25 0
> R/MarkInfo<</Marked true>>>>
 endobj
> 2 0 obj
> <</Type/Pages/Count 2/Kids[ 3 0 R 20 0 R] >>
> endobj
> 3 0 obj
> <</Type/Page/Parent 2 0 R/Resources<</ExtGState<</GS5 5 0 R/GS8 8 0
> R>>/Font<</F1 6 0 R/F2 11 0 R/F3 13 0 R/F4 15 0 R>>/XObject<</Image10 10 0
> R>>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 9 0 R] /MediaBox[ 0
> 0 595.32 841.92] /Contents 4 0
> R/Group<</Type/Group/S/Transparency/CS/DeviceRGB>>/Tabs/S/StructParents
(...)
Comment 4 enrico 2016-09-28 08:28:41 UTC
same behaviour here.
i've also found this workaround:
changing the standard templates by removing %QUOTE and adding both %TEXT and %FORCEDHTML show the original message(s) correctly but without quote.
Comment 5 m.eik michalke 2016-10-10 18:27:05 UTC
i think i have a similar issue with kmail 5.1.3, it only happens regularly with encrypted mails that came over a mailman list and have an unecrypted part appended (listinfo): when i hit "reply", only this last part -- the listinfo section -- is being used as reply text.

if the mail is encrypted as usual (no unencrypted parts), then kmail uses the unencrypted mail content for the reply.

i can work around the issue by selecting the actual text before "reply".
Comment 6 Laurent Montel 2016-10-14 14:55:26 UTC
I confirm it
Comment 7 Laurent Montel 2016-10-15 05:44:30 UTC
it's a bug in mimetreeparser:
We use:
void TemplateParser::processWithTemplate(const QString &tmpl)
{
    mOtp->parseObjectTree(mOrigMsg.data());
=>
void ObjectTreeParser::parseObjectTree(KMime::Content *node)
{
    mTopLevelContent = node;
    mParsedPart = parseObjectTreeInternal(node, showOnlyOneMimePart());

    if (mParsedPart) {
        mParsedPart->fix();
        mParsedPart->copyContentFrom();
        if (auto mp = toplevelTextNode(mParsedPart)) {
            if (auto _mp = mp.dynamicCast<TextMessagePart>()) {
                extractNodeInfos(_mp->mNode, true);
            } else if (auto _mp = mp.dynamicCast<AlternativeMessagePart>()) {
                if (_mp->mChildNodes.contains(Util::MultipartPlain)) {
                    extractNodeInfos(_mp->mChildNodes[Util::MultipartPlain], true);
                }
            }
            setPlainTextContent(mp->text());
        }

=> mp->text() seems to be not correct.

I CC 	Sandro Knauß  who needs better this code.

Regards
Comment 8 Simon Levitt 2016-10-26 00:35:45 UTC
This is the same problem as https://bugs.kde.org/show_bug.cgi?id=368060.

I've put a code hacky fix for this on that ticket.
Comment 9 Sandro Knauß 2016-10-26 14:37:18 UTC
The base problem is that a html mail with attachments, so lets merge

*** This bug has been marked as a duplicate of bug 368060 ***