From 32a6330a97d1fd63e328f23b7f396b621df5d33d Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 24 Aug 2007 18:48:32 +0000 Subject: [PATCH] Monotone-Parent: 0bde24af2d54dcd7bdb9395dcc3baf170b2a7d03 Monotone-Revision: e0d6bca914a4da0940a671160d74b221a1596487 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-08-24T18:48:32 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 5 +++++ UI/MailPartViewers/UIxMailPartViewer.m | 30 +++++++++++++++++--------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3bdbd22df..db41b9ec3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2007-08-24 Wolfgang Sourdeau + * UI/MailPartViewers/UIxMailPartViewer.m ([UIxMailPartViewer + -flatContentAsString]): use latin1 when the encoding is not + specified, and to reencode data chunk which were not correctly + decoded with the original charset. + * SoObjects/Appointments/SOGoAppointmentFolder.m ([SOGoAppointmentFolder -aclUsersForObjectAtPath:objectPathArray]) ([SOGoAppointmentFolder -aclsForUser:uidforObjectAtPath:objectPathArray]) ([SOGoAppointmentFolder -setRoles:rolesforUser:uidforObjectAtPath:objectPathArray]) diff --git a/UI/MailPartViewers/UIxMailPartViewer.m b/UI/MailPartViewers/UIxMailPartViewer.m index 36c2a1ad7..ab4ace1c3 100644 --- a/UI/MailPartViewers/UIxMailPartViewer.m +++ b/UI/MailPartViewers/UIxMailPartViewer.m @@ -164,7 +164,8 @@ return 0; } -- (NSString *)flatContentAsString { +- (NSString *) flatContentAsString +{ /* Note: we even have the line count in the body-info! */ NSString *charset; NSString *s; @@ -175,18 +176,27 @@ { charset = [[bodyInfo objectForKey:@"parameterList"] objectForKey: @"charset"]; - - // TODO: properly decode charset, might need to handle encoding? - - if ([charset length] > 0) - s = [NSString stringWithData: content - usingEncodingNamed: [charset lowercaseString]]; - else + charset = [charset lowercaseString]; + if (![charset length] + || [charset isEqualToString: @"us-ascii"]) { s = [[NSString alloc] initWithData: content - encoding: NSUTF8StringEncoding]; + encoding: NSISOLatin1StringEncoding]; [s autorelease]; } + else + { + s = [NSString stringWithData: content + usingEncodingNamed: charset]; + if (![s length]) + { + /* latin 1 is used as a 8bit fallback charset... but does this + encoding accept any byte from 0 to 255? */ + s = [[NSString alloc] initWithData: content + encoding: NSISOLatin1StringEncoding]; + [s autorelease]; + } + } if (!s) { @@ -302,7 +312,7 @@ - (NSString *) pathToAttachmentObject { /* this points to the SoObject representing the part, no modifications */ - NSString *url, *n, *pext; + NSString *url, *n; /* path to mail controller object */