Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions lib/CalDAV/Xml/Request/FreeBusyQueryReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 15 additions & 0 deletions tests/Sabre/CalDAV/FreeBusyReportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
<?xml version="1.0"?>
<c:free-busy-query xmlns:c="urn:ietf:params:xml:ns:caldav">
<c:time-range start="19900101" end="20400101"/>
</c:free-busy-query>
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);
}
}