diff --git a/ChangeLog b/ChangeLog index 5aa2b6522..dab6d37cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,13 @@ +2012-07-12 Jean Raby + + * SoObjects/Mailer/SOGoMailForward.m (from, to, cc, reply-to): + mailHeaders returns an array if there are multiple headers of the same type. + Handle this case to correctly show multiple from, to, cc and reply-to headers + in mail replies/forwards instead of crashing. + 2012-07-11 Ludovic Marcotte - * Finished the implementation and testing of the two + * Finished the implementation and testing of the two new defaults. Also added documentation in the SOGo Installation and Configuration Guide. diff --git a/NEWS b/NEWS index b61761c8b..f650b54ca 100644 --- a/NEWS +++ b/NEWS @@ -12,7 +12,7 @@ Enhancements limited to one additional address) Bug Fixes - - + - Fixed a crash when multiple mail header of the same type were encountered. 1.3.16 (2012-06-07) ------------------- diff --git a/SoObjects/Mailer/SOGoMailForward.m b/SoObjects/Mailer/SOGoMailForward.m index f652a4b0d..6d703d9b1 100644 --- a/SoObjects/Mailer/SOGoMailForward.m +++ b/SoObjects/Mailer/SOGoMailForward.m @@ -89,13 +89,13 @@ - (NSString *) from { - NSString *rc; + id rc; + rc = [[sourceMail mailHeaders] objectForKey: @"from"]; + if ([rc isKindOfClass: [NSArray class]]) + rc = [rc componentsJoinedByString: @", "]; if (htmlComposition) - rc = [[[sourceMail mailHeaders] objectForKey: @"from"] - stringByEscapingHTMLString]; - else - rc = [[sourceMail mailHeaders] objectForKey: @"from"]; + rc = [rc stringByEscapingHTMLString]; return rc; } @@ -119,13 +119,16 @@ - (NSString *) replyTo { - NSString *rc; + id rc; + rc = [self _headerField: @"reply-to"]; + if ([rc isKindOfClass: [NSArray class]]) + rc = [rc componentsJoinedByString: @", "]; if (htmlComposition) rc = [NSString stringWithFormat: @"%@
", - [[self _headerField: @"reply-to"] stringByEscapingHTMLString]]; + [rc stringByEscapingHTMLString]]; else - rc = ([NSString stringWithFormat: @"%@\n", [self _headerField: @"reply-to"]]); + rc = ([NSString stringWithFormat: @"%@\n", rc]); return rc; } @@ -149,12 +152,13 @@ - (NSString *) to { - NSString *rc; + id rc; + rc = [self _headerField: @"to"]; + if ([rc isKindOfClass: [NSArray class]]) + rc = [rc componentsJoinedByString: @", "]; if (htmlComposition) - rc = [[[sourceMail mailHeaders] objectForKey: @"to"] stringByEscapingHTMLString]; - else - rc = [[sourceMail mailHeaders] objectForKey: @"to"]; + rc = [rc stringByEscapingHTMLString]; return rc; } @@ -166,13 +170,17 @@ - (NSString *) cc { - NSString *rc; + id *rc; + + rc = [self _headerField: @"cc"]; + if ([rc isKindOfClass: [NSArray class]]) + rc = [rc componentsJoinedByString: @", "]; if (htmlComposition) rc = [NSString stringWithFormat: @"%@
", - [[self _headerField: @"cc"] stringByEscapingHTMLString]]; + [rc stringByEscapingHTMLString]]; else - rc = ([NSString stringWithFormat: @"%@\n", [self _headerField: @"cc"]]); + rc = [NSString stringWithFormat: @"%@\n", rc]; return rc; }