From d51d5c85b019950a34c67549400a64235c1c7581 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Tue, 1 Dec 2015 09:26:52 -0500 Subject: [PATCH] (fix) prevent characters in calendar component UID causing issues during import process --- NEWS | 1 + .../Appointments/SOGoAppointmentFolder.m | 24 +++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index e7e2d311c..190c1da46 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,7 @@ Bug fixes - EAS fix for wrong charset being used (#3392) - EAS fix on qp-encoded subjects (#3390) - correctly handle all-day event exceptions when the master event changes + - prevent characters in calendar component UID causing issues during import process 2.3.3a (2015-11-18) ------------------- diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index c85e79eb2..32ceb0fee 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -3160,19 +3160,29 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir NSMutableString *content; NSString *uid; - // We first look if there's an event with the same UID in our calendar. If not, - // let's reuse what is in the event, otherwise generate a new GUID and use it. + // We first look if the event has any / or + in its UID. If that's the case + // we generate a new UID based on a GUID uid = [event uid]; - object = [self lookupName: uid - inContext: context - acquire: NO]; - - if (object && ![object isKindOfClass: [NSException class]]) + if ([uid rangeOfCharacterFromSet: [NSCharacterSet characterSetWithCharactersInString: @"+/"]].location != NSNotFound) { uid = [self globallyUniqueObjectId]; [event setUid: uid]; } + else + { + // We also look if there's an event with the same UID in our calendar. If not, + // let's reuse what is in the event, otherwise generate a new GUID and use it. + object = [self lookupName: uid + inContext: context + acquire: NO]; + + if (object && ![object isKindOfClass: [NSException class]]) + { + uid = [self globallyUniqueObjectId]; + [event setUid: uid]; + } + } object = [SOGoAppointmentObject objectWithName: uid inContainer: self];