diff --git a/ChangeLog b/ChangeLog index 7ad9bda67..a0a308319 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-03-20 Wolfgang Sourdeau + + * UI/Scheduler/UIxComponentEditor.m + (-takeValuesFromRequest:inContext:): added some sanity checks to + avoid crashes when alarm data is not properly entered. + 2011-03-18 Francis Lachapelle * UI/WebServerResources/SchedulerUI.js (initCalendars): we must diff --git a/UI/Scheduler/UIxComponentEditor.m b/UI/Scheduler/UIxComponentEditor.m index 37930abd1..821e68027 100644 --- a/UI/Scheduler/UIxComponentEditor.m +++ b/UI/Scheduler/UIxComponentEditor.m @@ -2150,38 +2150,48 @@ RANGE(2); } else { // Custom alarm - [anAlarm setAction: [reminderAction uppercaseString]]; - if ([reminderAction isEqualToString: @"email"]) + if ([reminderAction length] > 0 && [reminderUnit length] > 0) { - [anAlarm removeAllAttendees]; - if (reminderEmailAttendees) - [self _appendAttendees: [component attendees] + [anAlarm setAction: [reminderAction uppercaseString]]; + if ([reminderAction isEqualToString: @"email"]) + { + [anAlarm removeAllAttendees]; + if (reminderEmailAttendees) + [self _appendAttendees: [component attendees] toEmailAlarm: anAlarm]; - if (reminderEmailOrganizer) - [self _appendOrganizerToEmailAlarm: anAlarm]; - [anAlarm setSummary: [component summary]]; - [anAlarm setComment: [component comment]]; + if (reminderEmailOrganizer) + [self _appendOrganizerToEmailAlarm: anAlarm]; + [anAlarm setSummary: [component summary]]; + [anAlarm setComment: [component comment]]; + } + + if ([reminderReference caseInsensitiveCompare: @"BEFORE"] == NSOrderedSame) + aValue = [NSString stringWithString: @"-P"]; + else + aValue = [NSString stringWithString: @"P"]; + + if ([reminderUnit caseInsensitiveCompare: @"MINUTES"] == NSOrderedSame || + [reminderUnit caseInsensitiveCompare: @"HOURS"] == NSOrderedSame) + aValue = [aValue stringByAppendingString: @"T"]; + + aValue = [aValue stringByAppendingFormat: @"%i%@", + [reminderQuantity intValue], + [reminderUnit substringToIndex: 1]]; + [aTrigger setValue: aValue]; + [aTrigger setRelationType: reminderRelation]; + } + else + { + [anAlarm release]; + anAlarm = nil; } - - if ([reminderReference caseInsensitiveCompare: @"BEFORE"] == NSOrderedSame) - aValue = [NSString stringWithString: @"-P"]; - else - aValue = [NSString stringWithString: @"P"]; - - if ([reminderUnit caseInsensitiveCompare: @"MINUTES"] == NSOrderedSame || - [reminderUnit caseInsensitiveCompare: @"HOURS"] == NSOrderedSame) - aValue = [aValue stringByAppendingString: @"T"]; - - aValue = [aValue stringByAppendingFormat: @"%i%@", - [reminderQuantity intValue], - [reminderUnit substringToIndex: 1]]; - [aTrigger setValue: aValue]; - [aTrigger setRelationType: reminderRelation]; } - [component removeAllAlarms]; - [component addToAlarms: anAlarm]; - - [anAlarm release]; + if (anAlarm) + { + [component removeAllAlarms]; + [component addToAlarms: anAlarm]; + [anAlarm release]; + } } if (![self isChildOccurence])