Bug 143237

Summary: Non multipart MIME mails containing only a single attachment fail
Product: [Unmaintained] kmail Reporter: Hans-Peter Jansen <hpj>
Component: mimeAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: djander, jean.robertson, mi+kde, neale, wbsoft, wstephenson
Priority: NOR    
Version: 1.9.5   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: send non multipart MIME mail containing a single attachment
small test pdf to play with..
My bad email
gzipped email that demonstrates the bug

Description Hans-Peter Jansen 2007-03-19 21:30:12 UTC
Version:           1.9.5 (using KDE KDE 3.5.5)
Installed from:    SuSE RPMs
OS:                Linux

It's quite popular to receive non multipart MIME mails containing a single attachment today, e.g. PDF invoices/delivery notices, and mails from all those Win* office users using "Mail this file".

Clicking on the attachment should open the related application in order to consume its content. Unfortunately, for kmail users it's not that easy, since the app either throws an error (ooo), or shows an more or less empty document (kpdf). But wait, viewing the "source code" of that message (key "V" in my german kmail) before clicking on the attachment "fixes" that problem (as long as this message is still shown).

This problem seems to exist for a long time, and persists in KDE 3.5.6 from SUSE BS, but today I finally got around to create a script, that generates such offending messages.

Use the "problem construction set" this way:
sendattachment.py -f from@x -t your@address -s \ mailserver.site -c 'application/pdf' testa.pdf

Check your INBOX, and try to view or save it. Check the result: the file should be damaged. Now view the message source and try again. It should work now, but is quite a hassle to explain this to users..

If you cannot reproduce it, let me know (I'm using Cyrus IMAP here).
Comment 1 Hans-Peter Jansen 2007-03-19 21:32:19 UTC
Created attachment 20040 [details]
send non multipart MIME mail containing a single attachment
Comment 2 Hans-Peter Jansen 2007-03-19 21:33:17 UTC
Created attachment 20041 [details]
small test pdf to play with..
Comment 3 Thomas McGuire 2007-03-20 14:51:59 UTC
Is this the same as bug 113516 maybe?
Comment 4 Thomas McGuire 2007-03-20 15:06:14 UTC
Actually, it could also be the same as bug 142068.
What happens if you save the attachment? Does it get truncated?
Does the message have the attachment flag in the message list?
Comment 5 Hans-Peter Jansen 2007-03-20 15:28:58 UTC
Hi Thomas, thanks for caring.

> Is this the same as bug 113516 maybe? 
> Actually, it could also be the same as bug 142068.

Yes, basically they're all the same problem! Sorry for not querying the 
problem exhaustively enough... 

> What happens if you save the attachment? Does it get truncated? 
Well, it's not truncated, it's way shorter than the original, but it's distorted, üzgül so to say:

-rw------- 1 hp site  365 20. Mär 15:23 tmp/MIMEmailwithsingle attachment.pdf
-rw-rw-r-- 1 hp site 8989 19. Mär 21:32 tmp/testa.pdf

> Does the message have the attachment flag in the message list? 
No.
 
This report has some advantages over the others, since it's formulated more general, tells a workaround, which will do for the others guys in the meantime, with the plus to being able to reproduce it with minimum effort. I'm sure, it gives a kmail developer enough hints to finally fix this ugly issue.. Thus I vote for "duplicating" the others.

From my POV, it's the most annoying issue with kmail in enterprise environments ATM.
Comment 6 Thomas McGuire 2007-03-20 15:46:32 UTC
>Hi Thomas, thanks for caring.
Don't get your hopes up, I'm just trying to make sure incoming bugs are no duplicates. I am not a KMail developer myself.

>This report has some advantages over the others, since it's formulated more general, tells a workaround, which will do for the others guys in the meantime, with the plus to being able to reproduce it with minimum effort. I'm sure, it gives a kmail developer enough hints to finally fix this ugly issue.. Thus I vote for "duplicating" the others. 
OK, I'll close them as duplicates.
 
Comment 7 Thomas McGuire 2007-03-20 15:47:17 UTC
*** Bug 142068 has been marked as a duplicate of this bug. ***
Comment 8 Thomas McGuire 2007-03-20 15:47:32 UTC
*** Bug 113516 has been marked as a duplicate of this bug. ***
Comment 9 Thomas McGuire 2007-03-20 15:58:26 UTC
There is a test mail available at http://woozle.org/~neale/tmp/T-Board Agenda for March 1 Meeting (from one of the dupliate reports).
However, I can not reproduce the problem with that mail (I saved it as text file and put it in my inbox folder). Saving and opening it with OOO from within KMail worked fine.
Comment 10 Neale Pickett 2007-03-20 21:45:26 UTC
Created attachment 20058 [details]
My bad email

This is probably less useful than the python script, but here's the email that
caused problems for me.  It will be removed from my web server soon.
Comment 11 Hans-Peter Jansen 2007-03-21 00:50:18 UTC
>> Hi Thomas, thanks for caring. 
> Don't get your hopes up, I'm just trying to make sure incoming bugs are no 
> duplicates. I am not a KMail developer myself.

Yup, I know, since I cursory follow kde-pim ML. They seem busy with kde4 stuff all the time. But nevertheless, you're doing something important for this great MUA and its developers. Hopefully, somebody will pick it up one day.

> This is probably less useful than the python script

Did someone from the kind audience tried to reproduce it with the script? Sure, I did, but I'm awaiting confirmation since I put this bug into SUSE bugzilla #120238, exactly one month ago :-( Needless to say, I haven't got a single reply there, that's why I'm here..
Comment 12 Thomas McGuire 2007-03-27 16:53:37 UTC
*** Bug 143490 has been marked as a duplicate of this bug. ***
Comment 13 Thomas McGuire 2007-04-29 19:59:44 UTC
*** Bug 144609 has been marked as a duplicate of this bug. ***
Comment 14 Thomas McGuire 2007-04-29 20:01:25 UTC
The reporter in bug 144609 says that turning off "load attachments on demand" works around this problem. 
So maybe this is only a problem for IMAP accounts.
Comment 15 Will Stephenson 2007-04-30 14:27:41 UTC
This was indeed the case.

Fixed by commit r653900
Comment 16 Thomas McGuire 2007-04-30 16:30:31 UTC
>Fixed by commit r653900 
Really? looks like a different thing to me:

>SVN commit 653900 by wstephens:

>Allow the user to cancel kmail connection attempts when the account
>settings are incorrect (Novell bug 247903).
>BUG:93199
Comment 17 Will Stephenson 2007-04-30 17:10:43 UTC
SVN commit 659645 by wstephens:

Add comment so that posterity can see that r653900 actually solved bug #143237.
CCBUG: 143237


 M  +2 -2      imapaccountbase.cpp  


--- branches/KDE/3.5/kdepim/kmail/imapaccountbase.cpp #659644:659645
@@ -1070,10 +1070,10 @@
       }
     }
     // if the only body part is not text, part->loadPart() would return false
-    // and that part is never loaded, so make sure it loads. 
+    // and that part is never loaded, so make sure it loads.
     // it seems that TEXT does load the single body part even if it is not text/*
     if ( mBodyPartList.count() == 1 && partsToLoad == 0 )
-        partsToLoad = 1;
+        partsToLoad = 1; // this causes the next test to succeed, and loads the whole message
 
     if ( (mBodyPartList.count() * 0.5) < partsToLoad )
     {
Comment 18 Will Stephenson 2007-04-30 17:11:52 UTC
My original commit message was incomplete, both #93199 and #143237 were fixed by the one commit.
Comment 19 Thomas McGuire 2007-04-30 17:17:15 UTC
> My original commit message was incomplete, both #93199 and #143237 were
> fixed by the one commit.

Ah OK, thanks!
Comment 20 Hans-Peter Jansen 2007-04-30 21:21:17 UTC
..and I confirm, that applying this patch to various kdepim versions from 3.4.0 to 3.5.6 fixes this ugly issue without any adverse effects.

Good work, Will.
Comment 21 Thomas McGuire 2007-07-19 21:35:22 UTC
*** Bug 127214 has been marked as a duplicate of this bug. ***
Comment 22 Lars DIECKOW 2008-01-25 14:11:10 UTC
Version: 1.9.7 (KDE 3.5.7, Gentoo)
Compiler: Target: i686-pc-linux-gnu
OS: Linux (i686) release 2.6.18-gentoo-r3

I confirm the bug as described in comment #1 of bug 113516, which has been marked as a duplicate of this bug. In the list pane the paperclip icon is not shown for messages that consist of a single non-text/* part.
Comment 23 Lars DIECKOW 2008-01-25 14:12:40 UTC
Created attachment 23270 [details]
gzipped email that demonstrates the bug
Comment 24 Will Stephenson 2008-01-27 10:40:48 UTC
Reopening so that the attachment indicator mentioned in comment #22 can be fixed
Comment 25 Martin Koller 2009-09-06 19:09:12 UTC
SVN commit 1020581 by mkoller:

BUG: 143237

Check for an attachment not only in the first BodyPart but in the Message itself if it has no first BodyPart.


 M  +8 -9      kmmessage.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1020581