From ae0ea2e242427ad80f04f4fcab1dc685ba417c47 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 10 Mar 2016 16:43:10 +0100 Subject: [PATCH] Prevent from fatal errors on events without end date (#5307) --- plugins/libkolab/lib/kolab_date_recurrence.php | 7 +++++-- plugins/libkolab/lib/kolab_format_event.php | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/libkolab/lib/kolab_date_recurrence.php b/plugins/libkolab/lib/kolab_date_recurrence.php index f2483c96..4f8ae61a 100644 --- a/plugins/libkolab/lib/kolab_date_recurrence.php +++ b/plugins/libkolab/lib/kolab_date_recurrence.php @@ -49,8 +49,11 @@ class kolab_date_recurrence if (is_object($data['start']) && is_object($data['end'])) $this->duration = $data['start']->diff($data['end']); - else - $this->duration = new DateInterval('PT' . ($data['end'] - $data['start']) . 'S'); + else { + // Prevent from errors when end date is not set (#5307) RFC5545 3.6.1 + $seconds = !empty($data['end']) ? ($data['end'] - $data['start']) : 0; + $this->duration = new DateInterval('PT' . $seconds . 'S'); + } } /** diff --git a/plugins/libkolab/lib/kolab_format_event.php b/plugins/libkolab/lib/kolab_format_event.php index 41a9745b..a7cf2d42 100644 --- a/plugins/libkolab/lib/kolab_format_event.php +++ b/plugins/libkolab/lib/kolab_format_event.php @@ -189,6 +189,10 @@ class kolab_format_event extends kolab_format_xcal $object['end'] = clone $object['start']; $object['end']->add($interval); } + // make sure end date is specified (#5307) RFC5545 3.6.1 + else if (!$object['end'] && $object['start']) { + $object['end'] = clone $object['start']; + } // organizer is part of the attendees list in Roundcube if ($object['organizer']) {