(fix) LDIF to vCard conversion for non-handled multi-value attributes (fixes #4086)

pull/236/head
Ludovic Marcotte 2017-04-21 12:31:18 -04:00
parent 2b4e357da6
commit 513d81eb59
9 changed files with 49 additions and 45 deletions

1
NEWS
View File

@ -15,6 +15,7 @@ Bug fixes
- [core] fix sogo-tool restore potentially crashing on corrupted data (#4048) - [core] fix sogo-tool restore potentially crashing on corrupted data (#4048)
- [core] handle properly mails using windows-1255 charset (#4124) - [core] handle properly mails using windows-1255 charset (#4124)
- [core] fixed email reminders sent multiple times (#4100) - [core] fixed email reminders sent multiple times (#4100)
- [core] fixed LDIF to vCard conversion for non-handled multi-value attributes (#4086)
- [eas] set reply/forwarded flags when ReplaceMime is set (#4133) - [eas] set reply/forwarded flags when ReplaceMime is set (#4133)
- [eas] remove alarms over EAS if we don't want them (#4059) - [eas] remove alarms over EAS if we don't want them (#4059)
- [eas] correctly set RSVP on event invitations - [eas] correctly set RSVP on event invitations

View File

@ -1,6 +1,6 @@
/* CardElement.h - this file is part of SOPE /* CardElement.h - this file is part of SOPE
* *
* Copyright (C) 2006-2014 Inverse inc. * Copyright (C) 2006-2017 Inverse inc.
* *
* This file is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -64,7 +64,7 @@
- (NSMutableDictionary *) values; - (NSMutableDictionary *) values;
/* ELEM:...;value1,value2,...;... */ /* ELEM:...;value1,value2,...;... */
- (void) setValues: (NSMutableArray *) newValues - (void) setValues: (id) newValues
atIndex: (NSUInteger) idx atIndex: (NSUInteger) idx
forKey: (NSString *) key; forKey: (NSString *) key;

View File

@ -1,6 +1,6 @@
/* CardElement.m - this file is part of SOPE /* CardElement.m - this file is part of SOPE
* *
* Copyright (C) 2006-2014 Inverse inc. * Copyright (C) 2006-2017 Inverse inc.
* *
* This file is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -130,12 +130,17 @@
return values; return values;
} }
- (void) setValues: (NSMutableArray *) newValues - (void) setValues: (id) newValues
atIndex: (NSUInteger) idx atIndex: (NSUInteger) idx
forKey: (NSString *) key forKey: (NSString *) key
{ {
NSMutableArray *oldValues, *subValues; NSMutableArray *oldValues, *subValues;
if ([newValues isKindOfClass: [NSString class]])
return [self setSingleValue: (NSString *)newValues
atIndex: idx
forKey: key];
oldValues = [self valuesForKey: key]; oldValues = [self valuesForKey: key];
if (!oldValues) if (!oldValues)
{ {

View File

@ -277,32 +277,32 @@ convention:
[self setFn: fn]; [self setFn: fn];
element = [self elementWithTag: @"adr" ofType: @"home"]; element = [self elementWithTag: @"adr" ofType: @"home"];
[element setSingleValue: [ldifRecord objectForKey: @"mozillahomestreet2"] [element setValues: [ldifRecord objectForKey: @"mozillahomestreet2"]
atIndex: 1 forKey: @""]; atIndex: 1 forKey: @""];
[element setSingleValue: [ldifRecord objectForKey: @"mozillahomestreet"] [element setValues: [ldifRecord objectForKey: @"mozillahomestreet"]
atIndex: 2 forKey: @""]; atIndex: 2 forKey: @""];
[element setSingleValue: [ldifRecord objectForKey: @"mozillahomelocalityname"] [element setValues: [ldifRecord objectForKey: @"mozillahomelocalityname"]
atIndex: 3 forKey: @""]; atIndex: 3 forKey: @""];
[element setSingleValue: [ldifRecord objectForKey: @"mozillahomestate"] [element setValues: [ldifRecord objectForKey: @"mozillahomestate"]
atIndex: 4 forKey: @""]; atIndex: 4 forKey: @""];
[element setSingleValue: [ldifRecord objectForKey: @"mozillahomepostalcode"] [element setValues: [ldifRecord objectForKey: @"mozillahomepostalcode"]
atIndex: 5 forKey: @""]; atIndex: 5 forKey: @""];
[element setSingleValue: [ldifRecord objectForKey: @"mozillahomecountryname"] [element setValues: [ldifRecord objectForKey: @"mozillahomecountryname"]
atIndex: 6 forKey: @""]; atIndex: 6 forKey: @""];
element = [self elementWithTag: @"adr" ofType: @"work"]; element = [self elementWithTag: @"adr" ofType: @"work"];
[element setSingleValue: [ldifRecord objectForKey: @"mozillaworkstreet2"] [element setValues: [ldifRecord objectForKey: @"mozillaworkstreet2"]
atIndex: 1 forKey: @""]; atIndex: 1 forKey: @""];
[element setSingleValue: [ldifRecord objectForKey: @"street"] [element setValues: [ldifRecord objectForKey: @"street"]
atIndex: 2 forKey: @""]; atIndex: 2 forKey: @""];
[element setSingleValue: [ldifRecord objectForKey: @"l"] [element setValues: [ldifRecord objectForKey: @"l"]
atIndex: 3 forKey: @""]; atIndex: 3 forKey: @""];
[element setSingleValue: [ldifRecord objectForKey: @"st"] [element setValues: [ldifRecord objectForKey: @"st"]
atIndex: 4 forKey: @""]; atIndex: 4 forKey: @""];
[element setSingleValue: [ldifRecord objectForKey: @"postalcode"] [element setValues: [ldifRecord objectForKey: @"postalcode"]
atIndex: 5 forKey: @""]; atIndex: 5 forKey: @""];
[element setSingleValue: [ldifRecord objectForKey: @"c"] [element setValues: [ldifRecord objectForKey: @"c"]
atIndex: 6 forKey: @""]; atIndex: 6 forKey: @""];
ou = [ldifRecord objectForKey: @"ou"]; ou = [ldifRecord objectForKey: @"ou"];
if ([ou isKindOfClass: [NSArray class]]) if ([ou isKindOfClass: [NSArray class]])
@ -321,13 +321,13 @@ convention:
[self _setPhoneValues: ldifRecord]; [self _setPhoneValues: ldifRecord];
[self _setEmails: ldifRecord]; [self _setEmails: ldifRecord];
[[self elementWithTag: @"url" ofType: @"home"] [[self elementWithTag: @"url" ofType: @"home"]
setSingleValue: [ldifRecord objectForKey: @"mozillahomeurl"] forKey: @""]; setValues: [ldifRecord objectForKey: @"mozillahomeurl"] forKey: @""];
[[self elementWithTag: @"url" ofType: @"work"] [[self elementWithTag: @"url" ofType: @"work"]
setSingleValue: [ldifRecord objectForKey: @"mozillaworkurl"] forKey: @""]; setValues: [ldifRecord objectForKey: @"mozillaworkurl"] forKey: @""];
[[self uniqueChildWithTag: @"x-aim"] [[self uniqueChildWithTag: @"x-aim"]
setSingleValue: [ldifRecord objectForKey: @"nsaimid"] setValues: [ldifRecord objectForKey: @"nsaimid"]
forKey: @""]; forKey: @""];
now = [NSCalendarDate date]; now = [NSCalendarDate date];
year = [[ldifRecord objectForKey: @"birthyear"] intValue]; year = [[ldifRecord objectForKey: @"birthyear"] intValue];

View File

@ -1,6 +1,6 @@
/* SOGoContactLDIFEntry.h - this file is part of SOGo /* SOGoContactLDIFEntry.h - this file is part of SOGo
* *
* Copyright (C) 2006-2016 Inverse inc. * Copyright (C) 2006-2017 Inverse inc.
* *
* This file is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/* SOGoContactLDIFEntry.m - this file is part of SOGo /* SOGoContactLDIFEntry.m - this file is part of SOGo
* *
* Copyright (C) 2006-2016 Inverse inc. * Copyright (C) 2006-2017 Inverse inc.
* *
* This file is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

View File

@ -1,8 +1,6 @@
/* NSDictionary+Utilities.h - this file is part of SOGo /* NSDictionary+Utilities.h - this file is part of SOGo
* *
* Copyright (C) 2007 Inverse inc. * Copyright (C) 2007-2017 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* *
* This file is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

View File

@ -1,8 +1,6 @@
/* NSDictionary+Utilities.m - this file is part of SOGo /* NSDictionary+Utilities.m - this file is part of SOGo
* *
* Copyright (C) 2007-2011 Inverse inc. * Copyright (C) 2007-2017 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* *
* This file is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

View File

@ -165,16 +165,17 @@
- (NSArray *) deliveryAddresses - (NSArray *) deliveryAddresses
{ {
NSMutableArray *addresses;
NSMutableDictionary *address;
NSArray *elements;
NSString *type, *postoffice, *street, *street2, *locality, *region, *postalcode, *country; NSString *type, *postoffice, *street, *street2, *locality, *region, *postalcode, *country;
NSMutableDictionary *address;
NSMutableArray *addresses;
NSArray *elements;
CardElement *adr; CardElement *adr;
NSUInteger count, max; NSUInteger count, max;
elements = [card childrenWithTag: @"adr"]; elements = [card childrenWithTag: @"adr"];
//values = [org valuesForKey: @""];
max = [elements count]; max = [elements count];
if (max > 0) if (max > 0)
{ {
addresses = [NSMutableArray arrayWithCapacity: max]; addresses = [NSMutableArray arrayWithCapacity: max];
@ -189,7 +190,8 @@
region = [adr flattenedValueAtIndex: 4 forKey: @""]; region = [adr flattenedValueAtIndex: 4 forKey: @""];
postalcode = [adr flattenedValueAtIndex: 5 forKey: @""]; postalcode = [adr flattenedValueAtIndex: 5 forKey: @""];
country = [adr flattenedValueAtIndex: 6 forKey: @""]; country = [adr flattenedValueAtIndex: 6 forKey: @""];
address = [NSMutableDictionary dictionaryWithObject: type forKey: @"type"];
address = [NSMutableDictionary dictionaryWithObject: type forKey: @"type"];
if (postoffice) [address setObject: postoffice forKey: @"postoffice"]; if (postoffice) [address setObject: postoffice forKey: @"postoffice"];
if (street2) [address setObject: street2 forKey: @"street2"]; if (street2) [address setObject: street2 forKey: @"street2"];
if (street) [address setObject: street forKey: @"street"]; if (street) [address setObject: street forKey: @"street"];