From 90f4187c98b05f7a5620f95b288fe9cc1e3218c5 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Thu, 26 Nov 2009 11:51:52 +0000 Subject: [PATCH] See ChangeLog Monotone-Parent: 5a7e429f43453ecb7e1ca7ac57a0e13f01a7d0be Monotone-Revision: bd604d08baed0cf7905c0c78a513a7e7a9621223 Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2009-11-26T11:51:52 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 9 +++++++ SoObjects/Mailer/SOGoMailObject+Draft.m | 28 +++++++++++++++++++--- UI/MailPartViewers/UIxMailPartHTMLViewer.m | 2 +- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index f87e2d1a1..d3bd2b0f3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-11-26 Ludovic Marcotte + + * SoObjects/Mailer/SOGoMailObject+Draft.m + (_fetchFileAttachmentKey:intoArray:withPath:): we + try to also use basic types (application/, audio/, ...) + when forwarding a mail with attachments and no + Content-Disposition header (or filename) was found. This + avoid losing attachments when forwarding mails. + 2009-11-24 Francis Lachapelle * SoObjects/Mailer/NSData+Mail.m (-decodedString): renamed from diff --git a/SoObjects/Mailer/SOGoMailObject+Draft.m b/SoObjects/Mailer/SOGoMailObject+Draft.m index 5b94238f8..030b6bdff 100644 --- a/SoObjects/Mailer/SOGoMailObject+Draft.m +++ b/SoObjects/Mailer/SOGoMailObject+Draft.m @@ -253,11 +253,13 @@ disposition = [part objectForKey: @"disposition"]; filename = [[disposition objectForKey: @"parameterList"] objectForKey: @"filename"]; + + mimeType = [NSString stringWithFormat: @"%@/%@", + [part objectForKey: @"type"], + [part objectForKey: @"subtype"]]; + if (filename) { - mimeType = [NSString stringWithFormat: @"%@/%@", - [part objectForKey: @"type"], - [part objectForKey: @"subtype"]]; currentFile = [NSDictionary dictionaryWithObjectsAndKeys: filename, @"filename", [mimeType lowercaseString], @"mimetype", @@ -265,6 +267,26 @@ [part objectForKey: @"encoding"], @"encoding", nil]; [keys addObject: currentFile]; } + else + { + // We might end up here because of MUA that actually strips the + // Content-Disposition (and thus, the filename) when mails containing + // attachments have been forwarded. Thunderbird (2.x) does just that + // when forwarding mails with images attached to them (using cid:...). + if ([mimeType hasPrefix: @"application/"] || + [mimeType hasPrefix: @"audio/"] || + [mimeType hasPrefix: @"image/"] || + [mimeType hasPrefix: @"video/"]) + { + currentFile = [NSDictionary dictionaryWithObjectsAndKeys: + [NSString stringWithFormat: @"unkown_%@", path], @"filename", + [mimeType lowercaseString], @"mimetype", + path, @"path", + [part objectForKey: @"encoding"], @"encoding", + nil]; + [keys addObject: currentFile]; + } + } } - (void) _fetchFileAttachmentKeysInPart: (NSDictionary *) part diff --git a/UI/MailPartViewers/UIxMailPartHTMLViewer.m b/UI/MailPartViewers/UIxMailPartHTMLViewer.m index 91b3e33de..7debb5d38 100644 --- a/UI/MailPartViewers/UIxMailPartHTMLViewer.m +++ b/UI/MailPartViewers/UIxMailPartHTMLViewer.m @@ -536,7 +536,7 @@ _xmlCharsetForCharset (NSString *charset) } [dump appendFormat: @"--- end ---\n"]; - NSLog (dump); + NSLog(dump); [dump release]; }