From e7ddfb0546fcb70f1ac3401375656936ea00c380 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Wed, 11 Jun 2014 12:55:51 -0400 Subject: [PATCH] Fix for bug #2805 --- ActiveSync/SOGoActiveSyncDispatcher.m | 45 +++++++++++++++++++++------ NEWS | 1 + 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/ActiveSync/SOGoActiveSyncDispatcher.m b/ActiveSync/SOGoActiveSyncDispatcher.m index e84e7f966..b98ce3bd2 100644 --- a/ActiveSync/SOGoActiveSyncDispatcher.m +++ b/ActiveSync/SOGoActiveSyncDispatcher.m @@ -1899,9 +1899,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. value = [theDocumentElement getElementsByTagName: @"ReplaceMime"]; - // ReplaceMime isn't specified so we must NOT use the server copy + // ReplaceMime IS specified so we must NOT use the server copy // but rather take the data as-is from the client. - if (![value count]) + if ([value count]) { [self processSendMail: theDocumentElement inResponse: theResponse]; @@ -1921,11 +1921,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NSData *data; NGMimeMessageGenerator *generator; - NGMimeBodyPart *bodyPart; + NGMimeBodyPart *bodyPart; NGMutableHashMap *map; NGMimeFileData *fdata; NSException *error; - id body; + + id body, bodyFromSmartForward; userFolder = [[context activeUser] homeFolderInContext: context]; accountsFolder = [userFolder lookupName: @"Mail" inContext: context acquire: NO]; @@ -1941,10 +1942,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. parser = [[NGMimeMessageParser alloc] init]; data = [[[[(id)[theDocumentElement getElementsByTagName: @"MIME"] lastObject] textValue] stringByDecodingBase64] dataUsingEncoding: NSUTF8StringEncoding]; messageFromSmartForward = [parser parsePartFromData: data]; - RELEASE(parser); - // We create a new MIME multipart/mixed message. The first part will be the text part // of our "smart forward" and the second part will be the message/rfc822 part of the // "smart forwarded" message. @@ -1954,11 +1953,39 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. messageToSend = [[[NGMimeMessage alloc] initWithHeader: map] autorelease]; body = [[[NGMimeMultipartBody alloc] initWithPart: messageToSend] autorelease]; - // First part + // First part - either a text/* or a multipart/*. If it's a multipart, + // we take the first part text/* part we see. map = [[[NGMutableHashMap alloc] initWithCapacity: 1] autorelease]; - [map setObject: @"text/plain" forKey: @"content-type"]; + bodyFromSmartForward = nil; + + if ([[messageFromSmartForward body] isKindOfClass: [NGMimeMultipartBody class]]) + { + NGMimeBodyPart *part; + NSArray *parts; + int i; + + parts = [[messageFromSmartForward body] parts]; + + for (i = 0; i < [parts count]; i++) + { + part = [parts objectAtIndex: i]; + + if ([[[part contentType] type] isEqualToString: @"text"]) + { + [map setObject: [[part contentType] stringValue] forKey: @"content-type"]; + bodyFromSmartForward = [part body]; + break; + } + } + } + else + { + [map setObject: [[messageFromSmartForward contentType] stringValue] forKey: @"content-type"]; + bodyFromSmartForward = [messageFromSmartForward body]; + } + bodyPart = [[[NGMimeBodyPart alloc] initWithHeader:map] autorelease]; - [bodyPart setBody: [messageFromSmartForward body]]; + [bodyPart setBody: bodyFromSmartForward]; [body addBodyPart: bodyPart]; // Second part diff --git a/NEWS b/NEWS index fb1aa4abe..c535e992a 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,7 @@ Bug fixes - better handling of empty "Flag" messages over ActiveSync (#2806) - fixed Chinese charset handling (#2809) - fixed folder name (calendars and contacts) of new subscriptions (#2801) + - fixed the reply/forward operation over ActiveSync (#2805) 2.2.5 (2014-06-05) ------------------