Monotone-Parent: e339a3442f42acdf4909a6baec00b5327ae53cb3
Monotone-Revision: ee950e307e6571a0c19bb8438551295e0126c17e Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-08-26T15:30:51 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
parent
a4488f234f
commit
14d3f1ae86
|
@ -1,5 +1,10 @@
|
|||
2010-08-26 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* SoObjects/Mailer/SOGoDraftObject.m (_quoteSpecials:): now work
|
||||
on single strings.
|
||||
(_quoteSpecialsInArray:): new method that offers the same
|
||||
functionality as _quoteSpecials: did before the change above.
|
||||
|
||||
* UI/MailerUI/UIxMailEditor.m (_emailFromIdentity:): the "from"
|
||||
field is handled in SOGoDraftObject, therefore we don't need to
|
||||
modify it here, especially since this will alterate the display.
|
||||
|
|
|
@ -1202,58 +1202,69 @@ static NSString *userAgent = nil;
|
|||
return NO;
|
||||
}
|
||||
|
||||
- (NSArray *) _quoteSpecials: (NSArray *) _array
|
||||
- (NSString *) _quoteSpecials: (NSString *) address
|
||||
{
|
||||
NSMutableArray *a;
|
||||
NSString *s1, *s2;
|
||||
int i, j, len;
|
||||
|
||||
a = [NSMutableArray array];
|
||||
NSString *result, *part, *s2;
|
||||
int i, len;
|
||||
|
||||
// We want to correctly send mails to recipients such as :
|
||||
// foo.bar
|
||||
// foo (bar) <foo@zot.com>
|
||||
// bar, foo <foo@zot.com>
|
||||
for (i = 0; i < [_array count]; i++)
|
||||
{
|
||||
s1 = [_array objectAtIndex: i];
|
||||
|
||||
if ([s1 indexOf: '('] >= 0 || [s1 indexOf: ')'] >= 0
|
||||
|| [s1 indexOf: '<'] >= 0 || [s1 indexOf: '>'] >= 0
|
||||
|| [s1 indexOf: '@'] >= 0 || [s1 indexOf: ','] >= 0
|
||||
|| [s1 indexOf: ';'] >= 0 || [s1 indexOf: ':'] >= 0
|
||||
|| [s1 indexOf: '\\'] >= 0 || [s1 indexOf: '"'] >= 0
|
||||
|| [s1 indexOf: '.'] >= 0
|
||||
|| [s1 indexOf: '['] >= 0 || [s1 indexOf: ']'] >= 0)
|
||||
if ([address indexOf: '('] >= 0 || [address indexOf: ')'] >= 0
|
||||
|| [address indexOf: '<'] >= 0 || [address indexOf: '>'] >= 0
|
||||
|| [address indexOf: '@'] >= 0 || [address indexOf: ','] >= 0
|
||||
|| [address indexOf: ';'] >= 0 || [address indexOf: ':'] >= 0
|
||||
|| [address indexOf: '\\'] >= 0 || [address indexOf: '"'] >= 0
|
||||
|| [address indexOf: '.'] >= 0
|
||||
|| [address indexOf: '['] >= 0 || [address indexOf: ']'] >= 0)
|
||||
{
|
||||
// We search for the first instance of < from the end
|
||||
// and we quote what was before if we need to
|
||||
len = [s1 length];
|
||||
j = -1;
|
||||
len = [address length];
|
||||
i = -1;
|
||||
while (len--)
|
||||
if ([s1 characterAtIndex: len] == '<')
|
||||
if ([address characterAtIndex: len] == '<')
|
||||
{
|
||||
j = len;
|
||||
i = len;
|
||||
break;
|
||||
}
|
||||
|
||||
if (j > 0)
|
||||
if (i > 0)
|
||||
{
|
||||
s2 = [s1 substringToIndex: j-1];
|
||||
s2 = [NSString stringWithFormat: @"\"%@\" %@", s2, [s1 substringFromIndex: j]];
|
||||
part = [address substringToIndex: i - 1];
|
||||
s2 = [[part stringByReplacingString: @"\\" withString: @"\\\\"]
|
||||
stringByReplacingString: @"\"" withString: @"\\\""];
|
||||
result = [NSString stringWithFormat: @"\"%@\" %@", s2, [address substringFromIndex: i]];
|
||||
}
|
||||
else
|
||||
{
|
||||
s2 = [NSString stringWithFormat: @"\"%@\"", s1];
|
||||
s2 = [[address stringByReplacingString: @"\\" withString: @"\\\\"]
|
||||
stringByReplacingString: @"\"" withString: @"\\\""];
|
||||
result = [NSString stringWithFormat: @"\"%@\"", s2];
|
||||
}
|
||||
|
||||
[a addObject: s2];
|
||||
}
|
||||
else
|
||||
[a addObject: s1];
|
||||
result = address;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return a;
|
||||
- (NSArray *) _quoteSpecialsInArray: (NSArray *) addresses
|
||||
{
|
||||
NSMutableArray *result;
|
||||
NSString *address;
|
||||
int count, max;
|
||||
|
||||
max = [addresses count];
|
||||
result = [NSMutableArray arrayWithCapacity: max];
|
||||
for (count = 0; count < max; count++)
|
||||
{
|
||||
address = [self _quoteSpecials: [addresses objectAtIndex: count]];
|
||||
[result addObject: address];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (NGMutableHashMap *) mimeHeaderMapWithHeaders: (NSDictionary *) _headers
|
||||
|
@ -1269,11 +1280,11 @@ static NSString *userAgent = nil;
|
|||
/* add recipients */
|
||||
|
||||
if ((emails = [headers objectForKey: @"to"]) != nil)
|
||||
[map setObjects: [self _quoteSpecials: emails] forKey: @"to"];
|
||||
[map setObjects: [self _quoteSpecialsInArray: emails] forKey: @"to"];
|
||||
if ((emails = [headers objectForKey: @"cc"]) != nil)
|
||||
[map setObjects: [self _quoteSpecials: emails] forKey: @"cc"];
|
||||
[map setObjects: [self _quoteSpecialsInArray: emails] forKey: @"cc"];
|
||||
if ((emails = [headers objectForKey: @"bcc"]) != nil)
|
||||
[map setObjects: [self _quoteSpecials: emails] forKey: @"bcc"];
|
||||
[map setObjects: [self _quoteSpecialsInArray: emails] forKey: @"bcc"];
|
||||
|
||||
/* add senders */
|
||||
|
||||
|
@ -1282,16 +1293,16 @@ static NSString *userAgent = nil;
|
|||
|
||||
if (![self isEmptyValue:from]) {
|
||||
if ([from isKindOfClass:[NSArray class]])
|
||||
[map setObjects: from forKey: @"from"];
|
||||
[map setObjects: [self _quoteSpecialsInArray: from] forKey: @"from"];
|
||||
else
|
||||
[map setObject: from forKey: @"from"];
|
||||
[map setObject: [self _quoteSpecials: from] forKey: @"from"];
|
||||
}
|
||||
|
||||
if (![self isEmptyValue: replyTo]) {
|
||||
if ([from isKindOfClass:[NSArray class]])
|
||||
[map setObjects:from forKey: @"reply-to"];
|
||||
[map setObjects: [self _quoteSpecialsInArray: from] forKey: @"reply-to"];
|
||||
else
|
||||
[map setObject:from forKey: @"reply-to"];
|
||||
[map setObject: [self _quoteSpecials: from] forKey: @"reply-to"];
|
||||
}
|
||||
else if (![self isEmptyValue:from])
|
||||
[map setObjects: [map objectsForKey: @"from"] forKey: @"reply-to"];
|
||||
|
|
Loading…
Reference in a new issue