diff --git a/ActiveSync/SOGoMailObject+ActiveSync.m b/ActiveSync/SOGoMailObject+ActiveSync.m index eb4fcff3e..7b0a008a4 100644 --- a/ActiveSync/SOGoMailObject+ActiveSync.m +++ b/ActiveSync/SOGoMailObject+ActiveSync.m @@ -285,20 +285,31 @@ struct GlobalObjectId { [self _sanitizedMIMEPart: body performed: b]; } - else if ([body isKindOfClass: [NSData class]] && + else if (([body isKindOfClass: [NSData class]] || [body isKindOfClass: [NSString class]]) && [[[thePart contentType] type] isEqualToString: @"text"] && ([[[thePart contentType] subType] isEqualToString: @"plain"] || [[[thePart contentType] subType] isEqualToString: @"html"])) { // We make sure everything is encoded in UTF-8 - NSString *charset, *s; NGMimeType *mimeType; - int encoding; + NSString *s; - charset = [[thePart contentType] valueOfParameter: @"charset"]; - encoding = [NGMimeType stringEncodingForCharset: charset]; + if ([body isKindOfClass: [NSData class]]) + { + NSString *charset; + int encoding; - s = [[NSString alloc] initWithData: body encoding: encoding]; - AUTORELEASE(s); + charset = [[thePart contentType] valueOfParameter: @"charset"]; + encoding = [NGMimeType stringEncodingForCharset: charset]; + + s = [[NSString alloc] initWithData: body encoding: encoding]; + AUTORELEASE(s); + } + else + { + // Handle situations when SOPE stupidly returns us a NSString + // This can happen for Content-Type: text/plain, Content-Transfer-Encoding: 8bit + s = body; + } if (s) { diff --git a/NEWS b/NEWS index 7ed8d9495..3a16650ee 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,7 @@ Bug fixes - avoid crashing when we forward an email with no Subject header - we no longer try to include attachments when replying to a mail - fixed ActiveSync repetitive events issues with "Weekly" and "Monthly" ones + - fixed ActiveSync text/plain parts re-encoding issues for Outlook 2.2.4 (2014-05-29) ------------------