diff --git a/lib/CalDAV/Xml/Request/FreeBusyQueryReport.php b/lib/CalDAV/Xml/Request/FreeBusyQueryReport.php index 17df05a78a..64bfc9ac93 100644 --- a/lib/CalDAV/Xml/Request/FreeBusyQueryReport.php +++ b/lib/CalDAV/Xml/Request/FreeBusyQueryReport.php @@ -75,12 +75,18 @@ public static function xmlDeserialize(Reader $reader) if (!$start && !$end) { throw new BadRequest('The freebusy report must have a time-range element'); } - if ($start) { - $start = DateTimeParser::parseDateTime($start); - } - if ($end) { - $end = DateTimeParser::parseDateTime($end); + + try { + if ($start) { + $start = DateTimeParser::parseDateTime($start); + } + if ($end) { + $end = DateTimeParser::parseDateTime($end); + } + } catch (\Throwable $e) { + throw new BadRequest($e->getMessage(), $e->getCode(), $e); } + $result = new self(); $result->start = $start; $result->end = $end; diff --git a/tests/Sabre/CalDAV/FreeBusyReportTest.php b/tests/Sabre/CalDAV/FreeBusyReportTest.php index ddf74b01a4..a3f0331f93 100644 --- a/tests/Sabre/CalDAV/FreeBusyReportTest.php +++ b/tests/Sabre/CalDAV/FreeBusyReportTest.php @@ -155,4 +155,19 @@ public function testFreeBusyReportNoACLPlugin() $report = $this->server->xml->parse($reportXML, null, $rootElem); $this->plugin->report($rootElem, $report, null); } + + public function testFreeBusyReportInvalidTimeRange() + { + $reportXML = << + + + +XML; + $this->expectException(\Sabre\DAV\Exception\BadRequest::class); + $this->expectExceptionMessage('The supplied iCalendar datetime value is incorrect: 19900101'); + + $report = $this->server->xml->parse($reportXML, null, $rootElem); + $this->plugin->report($rootElem, $report, null); + } }