From 995ccb2b736ec08154fcff371377d29b42888df9 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Tue, 9 Oct 2018 14:47:22 -0400 Subject: [PATCH] (fix) avoid saving non-parsable events/tasks --- SoObjects/Appointments/SOGoAppointmentObject.m | 8 ++++++++ SoObjects/Appointments/SOGoTaskObject.m | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/SoObjects/Appointments/SOGoAppointmentObject.m b/SoObjects/Appointments/SOGoAppointmentObject.m index a15837e5b..661d823cc 100644 --- a/SoObjects/Appointments/SOGoAppointmentObject.m +++ b/SoObjects/Appointments/SOGoAppointmentObject.m @@ -2503,6 +2503,14 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent rq = [_ctx request]; rqCalendar = [iCalCalendar parseSingleFromSource: [rq contentAsString]]; + + // We are unable to parse the received calendar, we return right away + // with a 400 error code. + if (!rqCalendar) + { + return [NSException exceptionWithHTTPStatus: 400 + reason: @"Unable to parse event."]; + } if (![self isNew]) { diff --git a/SoObjects/Appointments/SOGoTaskObject.m b/SoObjects/Appointments/SOGoTaskObject.m index 8bb4b500e..563f3fcbf 100644 --- a/SoObjects/Appointments/SOGoTaskObject.m +++ b/SoObjects/Appointments/SOGoTaskObject.m @@ -118,6 +118,15 @@ rq = [_ctx request]; rqCalendar = [iCalCalendar parseSingleFromSource: [rq contentAsString]]; + + // We are unable to parse the received calendar, we return right away + // with a 400 error code. + if (!rqCalendar) + { + return [NSException exceptionWithHTTPStatus: 400 + reason: @"Unable to parse task."]; + } + [self adjustClassificationInRequestCalendar: rqCalendar]; [rq setContent: [[rqCalendar versitString] dataUsingEncoding: [rq contentEncoding]]];