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]; }