From e4ad088f0dea27f9c062aa724b4df653e02496c2 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Tue, 3 Sep 2019 13:34:35 -0400 Subject: [PATCH] (fix) avoid exceptions for RRULE with no DTSTART --- NEWS | 1 + SOPE/NGCards/iCalDailyRecurrenceCalculator.m | 4 ++++ SOPE/NGCards/iCalWeeklyRecurrenceCalculator.m | 4 ++++ SOPE/NGCards/iCalYearlyRecurrenceCalculator.m | 6 +++++- SoObjects/Appointments/SOGoAppointmentFolder.m | 6 ++++++ 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index f2d443da0..d8a3002b1 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,7 @@ Bug fixes - [core] honor IMAPLoginFieldName also when setting IMAP ACLs - [core] honor groups when setting IMAP ACLs - [core] honor "any authenticated user" when setting IMAP ACLs + - [core] avoid exceptions for RRULE with no DTSTART 4.0.8 (2019-07-19) ------------------ diff --git a/SOPE/NGCards/iCalDailyRecurrenceCalculator.m b/SOPE/NGCards/iCalDailyRecurrenceCalculator.m index 6780661e2..a120ea6bd 100644 --- a/SOPE/NGCards/iCalDailyRecurrenceCalculator.m +++ b/SOPE/NGCards/iCalDailyRecurrenceCalculator.m @@ -69,6 +69,10 @@ dayMask = nil; repeatCount = 0; + if (!firstRange) + // Can happen when event/todo has a rrule with no dtstart + return nil; + if ([endDate compare: firStart] == NSOrderedAscending) // Range ends before first occurrence return nil; diff --git a/SOPE/NGCards/iCalWeeklyRecurrenceCalculator.m b/SOPE/NGCards/iCalWeeklyRecurrenceCalculator.m index 7fa4ba807..2ec0b7aa1 100644 --- a/SOPE/NGCards/iCalWeeklyRecurrenceCalculator.m +++ b/SOPE/NGCards/iCalWeeklyRecurrenceCalculator.m @@ -79,6 +79,10 @@ repeatCount = 0; hasRepeatCount = [rrule hasRepeatCount]; + if (!firstRange) + // Can happen when event/todo has a rrule with no dtstart + return nil; + if ([endDate compare: firStart] == NSOrderedAscending) // Range ends before first occurrence return nil; diff --git a/SOPE/NGCards/iCalYearlyRecurrenceCalculator.m b/SOPE/NGCards/iCalYearlyRecurrenceCalculator.m index 124b062ba..20195447e 100644 --- a/SOPE/NGCards/iCalYearlyRecurrenceCalculator.m +++ b/SOPE/NGCards/iCalYearlyRecurrenceCalculator.m @@ -59,7 +59,11 @@ repeatCount = 0; count = 0; referenceDate = nil; - + + if (!firstRange) + // Can happen when event/todo has a rrule with no dtstart + return nil; + if ([rEnd compare: firStart] == NSOrderedAscending) // Range ends before first occurrence return nil; diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 56a8d793f..4bd77e0e5 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -1100,6 +1100,12 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir endDate = [(iCalToDo*) component due]; } + if (![master startDate]) + { + [self errorWithFormat: @"ignored component with no DTSTART"]; + return; + } + delta = [masterEndDate timeIntervalSinceDate: [master startDate]]; recurrenceIdRange = [NGCalendarDateRange calendarDateRangeWithStartDate: recurrenceId endDate: [recurrenceId dateByAddingYears:0 months:0 days:0 hours:0 minutes:0 seconds: delta]];