diff --git a/NEWS b/NEWS index febbbe8be..7a2bb791d 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,7 @@ Bug fixes - [web] fixed recipients when replying from a message in the Sent mailbox (#2625) - [web] fixed localizable strings in Card viewer - [web] properly encode HTML attributes in Contacts module to avoid XSS issues + - [web] handle c_mail field format of quick record of contacts of v3 (#3443) 2.3.11 (2016-05-12) ------------------- diff --git a/SoObjects/Contacts/NGVCard+SOGo.m b/SoObjects/Contacts/NGVCard+SOGo.m index 8320680b7..d59d91798 100644 --- a/SoObjects/Contacts/NGVCard+SOGo.m +++ b/SoObjects/Contacts/NGVCard+SOGo.m @@ -1,6 +1,6 @@ /* NGVCard+SOGo.m - this file is part of SOGo * - * Copyright (C) 2009-2014 Inverse inc. + * Copyright (C) 2009-2015 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,11 +18,6 @@ * Boston, MA 02111-1307, USA. */ -#import -#import -#import -#import -#import #import @@ -50,7 +45,7 @@ objectclass ( 2.5.6.7 NAME 'organizationalPerson' SUP person STRUCTURAL MAY ( title $ x121Address $ registeredAddress $ destinationIndicator $ preferredDeliveryMethod $ telexNumber $ teletexTerminalIdentifier $ - telephoneNumber $ internationaliSDNNumber $ + telephoneNumber $ internationaliSDNNumber $ facsimileTelephoneNumber $ street $ postOfficeBox $ postalCode $ postalAddress $ physicalDeliveryOfficeName $ ou $ st $ l ) ) @@ -69,10 +64,10 @@ objectclass ( 2.16.840.1.113730.3.2.2 userSMIMECertificate $ userPKCS12 ) ) -objectclass ( 1.3.6.1.4.1.13769.9.1 NAME 'mozillaAbPersonAlpha' - SUP top AUXILIARY +objectclass ( 1.3.6.1.4.1.13769.9.1 NAME 'mozillaAbPersonAlpha' + SUP top AUXILIARY MUST ( cn ) - MAY( c $ + MAY( c $ description $ displayName $ facsimileTelephoneNumber $ @@ -225,15 +220,19 @@ convention: CardElement *element; NSCalendarDate *now; NSArray *units; - NSString *ou; + NSString *fn, *ou; id o; [self setNWithFamily: [ldifRecord objectForKey: @"sn"] given: [ldifRecord objectForKey: @"givenname"] additional: nil prefixes: nil suffixes: nil]; [self setNickname: [ldifRecord objectForKey: @"mozillanickname"]]; - [self setFn: [ldifRecord objectForKey: @"displayname"]]; - [self setTitle: [ldifRecord objectForKey: @"title"]]; + [self setTitle: [ldifRecord objectForKey: @"title"]]; + + fn = [ldifRecord objectForKey: @"displayname"]; + if (!fn) + fn = [ldifRecord objectForKey: @"cn"]; + [self setFn: fn]; element = [self elementWithTag: @"adr" ofType: @"home"]; [element setSingleValue: [ldifRecord objectForKey: @"mozillahomestreet2"] @@ -265,7 +264,7 @@ convention: ou = [ldifRecord objectForKey: @"ou"]; if ([ou isKindOfClass: [NSArray class]]) - units = [NSArray arrayWithArray: ou]; + units = [NSArray arrayWithArray: (NSArray *)ou]; else if (ou) units = [NSArray arrayWithObject: ou]; else @@ -279,7 +278,7 @@ convention: setSingleValue: [ldifRecord objectForKey: @"mozillahomeurl"] forKey: @""]; [[self elementWithTag: @"url" ofType: @"work"] setSingleValue: [ldifRecord objectForKey: @"mozillaworkurl"] forKey: @""]; - + [[self uniqueChildWithTag: @"x-aim"] setSingleValue: [ldifRecord objectForKey: @"nsaimid"] forKey: @""]; @@ -314,7 +313,7 @@ convention: o = [ldifRecord objectForKey: @"vcardcategories"]; - // We can either have an array (from SOGo's web gui) or a + // We can either have an array (from SOGo's web gui) or a // string (from a LDIF import) as the value here. if ([o isKindOfClass: [NSArray class]]) [self setCategories: o]; @@ -327,7 +326,7 @@ convention: /* VCARD -> LDIF */ - (NSString *) _simpleValueForType: (NSString *) aType inArray: (NSArray *) anArray - excluding: (NSString *) aTypeToExclude + excluding: (NSString *) aTypeToExclude { NSArray *elements; NSString *value; @@ -348,7 +347,7 @@ convention: if (!aTypeToExclude) break; - + if (![ce hasAttribute: @"type" havingValue: aTypeToExclude]) break; @@ -580,8 +579,8 @@ convention: to: [self _simpleValueForType: @"home" inArray: elements excluding: nil] inLDIFRecord: ldifRecord]; - - // If we don't have a "work" or "home" URL but we still have + + // If we don't have a "work" or "home" URL but we still have // an URL field present, let's add it to the "home" value if ([[ldifRecord objectForKey: @"mozillaworkurl"] length] == 0 && [[ldifRecord objectForKey: @"mozillahomeurl"] length] == 0 && @@ -611,7 +610,7 @@ convention: } } } - + [self _setValue: @"title" to: [self title] inLDIFRecord: ldifRecord]; [self _setupOrgFieldsInLDIFRecord: ldifRecord]; @@ -654,7 +653,7 @@ convention: { CardElement *org; NSString *company; - + org = [self org]; company = [org flattenedValueAtIndex: 0 forKey: @""]; if ([company length] == 0) @@ -667,7 +666,7 @@ convention: { CardElement *n; NSString *fn, *firstName, *lastName, *org; - + fn = [self fn]; if ([fn length] == 0) { @@ -694,6 +693,29 @@ convention: return fn; } +- (NSArray *) emails +{ + NSArray *elements; + NSMutableArray *emails; + NSString *email; + int i; + + emails = [NSMutableArray array]; + elements = [self childrenWithTag: @"email"]; + + for (i = [elements count]-1; i >= 0; i--) + { + email = [[elements objectAtIndex: i] flattenedValuesForKey: @""]; + if ([email caseInsensitiveCompare: [self preferredEMail]] == NSOrderedSame) + // First element of array is the preferred email address + [emails insertObject: email atIndex: 0]; + else + [emails addObject: email]; + } + + return emails; +} + - (NSArray *) secondaryEmails { NSMutableArray *emails; @@ -706,11 +728,11 @@ convention: [emails removeObjectsInArray: [self childrenWithTag: @"email" andAttribute: @"type" havingValue: @"pref"]]; - + for (i = [emails count]-1; i >= 0; i--) { email = [[emails objectAtIndex: i] flattenedValuesForKey: @""]; - + if ([email caseInsensitiveCompare: [self preferredEMail]] == NSOrderedSame) [emails removeObjectAtIndex: i]; } @@ -742,7 +764,7 @@ convention: if (!aTypeToExclude) break; - + if (![ce hasAttribute: @"type" havingValue: aTypeToExclude]) break; @@ -795,7 +817,7 @@ convention: andShortTimeString: nil inTimeZone: [NSTimeZone timeZoneWithName: @"GMT"]]; } - + return date; } @@ -820,10 +842,12 @@ convention: value = [self preferredTel]; if (value) [fields setObject: value forKey: @"c_telephonenumber"]; - value = [self preferredEMail]; - if (![value isNotNull]) - value = @""; - [fields setObject: value forKey: @"c_mail"]; + v = [self emails]; + if ([v count] > 0) + [fields setObject: [v componentsJoinedByString: @","] + forKey: @"c_mail"]; + else + [fields setObject: [NSNull null] forKey: @"c_mail"]; element = [self org]; [fields setObject: [element flattenedValueAtIndex: 0 forKey: @""] forKey: @"c_o"]; diff --git a/SoObjects/Contacts/SOGoContactGCSFolder.m b/SoObjects/Contacts/SOGoContactGCSFolder.m index 290f5d27c..edfbdde30 100644 --- a/SoObjects/Contacts/SOGoContactGCSFolder.m +++ b/SoObjects/Contacts/SOGoContactGCSFolder.m @@ -228,7 +228,15 @@ static NSArray *folderListingFields = nil; } } - if (![contactRecord objectForKey: @"c_mail"]) + data = [contactRecord objectForKey: @"c_mail"]; + if ([data length]) + { + // We return the first email address only + // (We only benefit from all email addresses in v3) + NSArray *values = [data componentsSeparatedByString: @","]; + [contactRecord setObject: [values objectAtIndex: 0] forKey: @"c_mail"]; + } + else [contactRecord setObject: @"" forKey: @"c_mail"]; if (![contactRecord objectForKey: @"c_screenname"]) [contactRecord setObject: @"" forKey: @"c_screenname"];