File tree Expand file tree Collapse file tree 2 files changed +26
-5
lines changed
Expand file tree Collapse file tree 2 files changed +26
-5
lines changed Original file line number Diff line number Diff line change @@ -75,12 +75,18 @@ public static function xmlDeserialize(Reader $reader)
7575 if (!$ start && !$ end ) {
7676 throw new BadRequest ('The freebusy report must have a time-range element ' );
7777 }
78- if ($ start ) {
79- $ start = DateTimeParser::parseDateTime ($ start );
80- }
81- if ($ end ) {
82- $ end = DateTimeParser::parseDateTime ($ end );
78+
79+ try {
80+ if ($ start ) {
81+ $ start = DateTimeParser::parseDateTime ($ start );
82+ }
83+ if ($ end ) {
84+ $ end = DateTimeParser::parseDateTime ($ end );
85+ }
86+ } catch (\Throwable $ e ) {
87+ throw new BadRequest ($ e ->getMessage (), $ e ->getCode (), $ e );
8388 }
89+
8490 $ result = new self ();
8591 $ result ->start = $ start ;
8692 $ result ->end = $ end ;
Original file line number Diff line number Diff line change @@ -155,4 +155,19 @@ public function testFreeBusyReportNoACLPlugin()
155155 $ report = $ this ->server ->xml ->parse ($ reportXML , null , $ rootElem );
156156 $ this ->plugin ->report ($ rootElem , $ report , null );
157157 }
158+
159+ public function testFreeBusyReportInvalidTimeRange ()
160+ {
161+ $ reportXML = <<<XML
162+ <?xml version="1.0"?>
163+ <c:free-busy-query xmlns:c="urn:ietf:params:xml:ns:caldav">
164+ <c:time-range start="19900101" end="20400101"/>
165+ </c:free-busy-query>
166+ XML ;
167+ $ this ->expectException (\Sabre \DAV \Exception \BadRequest::class);
168+ $ this ->expectExceptionMessage ('The supplied iCalendar datetime value is incorrect: 19900101 ' );
169+
170+ $ report = $ this ->server ->xml ->parse ($ reportXML , null , $ rootElem );
171+ $ this ->plugin ->report ($ rootElem , $ report , null );
172+ }
158173}
You can’t perform that action at this time.
0 commit comments