From eebf878e896bd7b1395e4b2bdcb7a93d320c80ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrique=20J=2E=20Hern=C3=A1ndez=20Blasco?= Date: Wed, 30 Sep 2015 11:35:12 +0200 Subject: [PATCH] Ignore recurrence-id vevents without dtstart and outside date range Happened in an imported vevent from Mozilla Thunderbird. The crash was: Sep 14 15:49:38 sogod [21063]: <0x6442DBF8[SOGoAppointmentFolder]:personal> missing 'c_startdate' in record? Sep 14 15:49:38 sogod [21063]: <0x6442DBF8[SOGoAppointmentFolder]:personal> missing 'c_enddate' in record? 2015-09-14 15:49:38.927 sogod[21063] NGCalendarDateRange.m:37 Assertion failed in NGCalendarDateRange(instance), method initWithStartDate:endDate:. startDate MUST NOT be nil! EXCEPTION: NAME:NSInternalInconsistencyException REASON:NGCalendarDateRange.m:37 Assertion failed in NGCalendarDateRange(instance), method initWithStartDate:endDate:. startDate MUST NOT be nil! INFO:(null) The relevant ICS file lines are the following ones: BEGIN:VEVENT UID:040000008200E00074C5B7101A82E00800000000901646A7234BCE01000000000000000010000000E9152C8FF1C27D488C91967FAAFCC2B0 RECURRENCE-ID:20140513T100000Z DURATION:PT1H CLASS:PUBLIC ATTENDEE;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT;RSVP=TRUE;CN=krsny >> Ann Thierry K:mailto:krsny@example.com END:VEVENT --- .../Appointments/SOGoAppointmentFolder.m | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 3ff2b26ec..a73b98e5f 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -1063,7 +1063,7 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir { if ([dateRange containsDate: [component startDate]]) { - // We must pass nill to :container here in order to avoid re-entrancy issues. + // We must pass nil to :container here in order to avoid re-entrancy issues. newRecord = [self _fixupRecord: [component quickRecordFromContent: nil container: nil]]; [ma replaceObjectAtIndex: recordIndex withObject: newRecord]; } @@ -1080,15 +1080,20 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir { // The recurrence id of the exception is outside the date range; // simply add the exception to the records array. - // We must pass nill to :container here in order to avoid re-entrancy issues. + // We must pass nil to :container here in order to avoid re-entrancy issues. newRecord = [self _fixupRecord: [component quickRecordFromContent: nil container: nil]]; - newRecordRange = [NGCalendarDateRange - calendarDateRangeWithStartDate: [newRecord objectForKey: @"startDate"] - endDate: [newRecord objectForKey: @"endDate"]]; - if ([dateRange doesIntersectWithDateRange: newRecordRange]) + if ([newRecord objectForKey: @"startDate"] && [newRecord objectForKey: @"endDate"]) { + newRecordRange = [NGCalendarDateRange + calendarDateRangeWithStartDate: [newRecord objectForKey: @"startDate"] + endDate: [newRecord objectForKey: @"endDate"]]; + if ([dateRange doesIntersectWithDateRange: newRecordRange]) [ma addObject: newRecord]; - else + else + newRecord = nil; + } else { + [self warnWithFormat: @"Recurrence %@ without dtstart or dtend. Ignoring", recurrenceId]; newRecord = nil; + } } if (newRecord)