Skip to content

Commit fbe4821

Browse files
committed
Merge branch '2.1' into 3.0
2 parents 0e1df66 + 393dc0e commit fbe4821

File tree

3 files changed

+117
-2
lines changed

3 files changed

+117
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ChangeLog
22
=========
33

4-
3.0.2 (2015-??-??)
4+
3.0.2 (2015-07-21)
55
------------------
66

77
* #657: Migration script would break when coming a cross an iCalendar object
@@ -173,11 +173,14 @@ ChangeLog
173173
* #193: Fix `Sabre\DAV\FSExt\Directory::getQuotaInfo()` on windows.
174174

175175

176-
2.1.6 (2015-??-??)
176+
2.1.6 (2015-07-21)
177177
------------------
178178

179179
* #657: Migration script would break when coming a cross an iCalendar object
180180
with no UID.
181+
* #691: Workaround for broken Windows Phone client.
182+
* The zip release ships with [sabre/vobject 3.4.5][vobj],
183+
[sabre/http 3.0.5][http], and [sabre/event 2.0.2][evnt].
181184

182185

183186
2.1.5 (2015-07-11)

lib/CalDAV/Plugin.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,19 @@ function calendarQueryReport($report) {
576576

577577
}
578578

579+
if ($node instanceof ICalendarObjectContainer && $depth === 0) {
580+
581+
if(strpos($this->server->httpRequest->getHeader('User-Agent'), 'MSFT-WP/') === 0) {
582+
// Windows phone incorrectly supplied depth as 0, when it actually
583+
// should have set depth to 1. We're implementing a workaround here
584+
// to deal with this.
585+
$depth = 1;
586+
} else {
587+
throw new BadRequest('A calendar-query REPORT on a calendar with a Depth: 0 is undefined. Set Depth to 1');
588+
}
589+
590+
}
591+
579592
// If we're dealing with a calendar, the calendar itself is responsible
580593
// for the calendar-query.
581594
if ($node instanceof ICalendarObjectContainer && $depth == 1) {

tests/Sabre/CalDAV/PluginTest.php

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,105 @@ function testCalendarQueryReport() {
732732

733733
}
734734

735+
/**
736+
* @depends testSupportedReportSetProperty
737+
* @depends testCalendarMultiGetReport
738+
*/
739+
function testCalendarQueryReportWindowsPhone() {
740+
741+
$body =
742+
'<?xml version="1.0"?>' .
743+
'<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">' .
744+
'<d:prop>' .
745+
' <c:calendar-data>' .
746+
' <c:expand start="20000101T000000Z" end="20101231T235959Z" />' .
747+
' </c:calendar-data>' .
748+
' <d:getetag />' .
749+
'</d:prop>' .
750+
'<c:filter>' .
751+
' <c:comp-filter name="VCALENDAR">' .
752+
' <c:comp-filter name="VEVENT" />' .
753+
' </c:comp-filter>' .
754+
'</c:filter>' .
755+
'</c:calendar-query>';
756+
757+
$request = HTTP\Sapi::createFromServerArray(array(
758+
'REQUEST_METHOD' => 'REPORT',
759+
'REQUEST_URI' => '/calendars/user1/UUID-123467',
760+
'HTTP_USER_AGENT' => 'MSFT-WP/8.10.14219 (gzip)',
761+
'HTTP_DEPTH' => '0',
762+
));
763+
$request->setBody($body);
764+
765+
$this->server->httpRequest = $request;
766+
$this->server->exec();
767+
768+
$this->assertEquals(207, $this->response->status,'Received an unexpected status. Full response body: ' . $this->response->body);
769+
770+
$expectedIcal = TestUtil::getTestCalendarData();
771+
$expectedIcal = \Sabre\VObject\Reader::read($expectedIcal);
772+
$expectedIcal->expand(
773+
new \DateTime('2000-01-01 00:00:00', new \DateTimeZone('UTC')),
774+
new \DateTime('2010-12-31 23:59:59', new \DateTimeZone('UTC'))
775+
);
776+
$expectedIcal = str_replace("\r\n", "&#xD;\n", $expectedIcal->serialize());
777+
778+
$expected = <<<XML
779+
<?xml version="1.0"?>
780+
<d:multistatus xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
781+
<d:response>
782+
<d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>
783+
<d:propstat>
784+
<d:prop>
785+
<cal:calendar-data>$expectedIcal</cal:calendar-data>
786+
<d:getetag>"e207e33c10e5fb9c12cfb35b5d9116e1"</d:getetag>
787+
</d:prop>
788+
<d:status>HTTP/1.1 200 OK</d:status>
789+
</d:propstat>
790+
</d:response>
791+
</d:multistatus>
792+
XML;
793+
794+
$this->assertXmlStringEqualsXmlString($expected, $this->response->getBodyAsString());
795+
796+
}
797+
798+
/**
799+
* @depends testSupportedReportSetProperty
800+
* @depends testCalendarMultiGetReport
801+
*/
802+
function testCalendarQueryReportBadDepth() {
803+
804+
$body =
805+
'<?xml version="1.0"?>' .
806+
'<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">' .
807+
'<d:prop>' .
808+
' <c:calendar-data>' .
809+
' <c:expand start="20000101T000000Z" end="20101231T235959Z" />' .
810+
' </c:calendar-data>' .
811+
' <d:getetag />' .
812+
'</d:prop>' .
813+
'<c:filter>' .
814+
' <c:comp-filter name="VCALENDAR">' .
815+
' <c:comp-filter name="VEVENT" />' .
816+
' </c:comp-filter>' .
817+
'</c:filter>' .
818+
'</c:calendar-query>';
819+
820+
$request = HTTP\Sapi::createFromServerArray(array(
821+
'REQUEST_METHOD' => 'REPORT',
822+
'REQUEST_URI' => '/calendars/user1/UUID-123467',
823+
'HTTP_DEPTH' => '0',
824+
));
825+
$request->setBody($body);
826+
827+
$this->server->httpRequest = $request;
828+
$this->server->exec();
829+
830+
$this->assertEquals(400, $this->response->status,'Received an unexpected status. Full response body: ' . $this->response->body);
831+
832+
}
833+
735834
/**
736835
* @depends testCalendarQueryReport
737836
*/

0 commit comments

Comments
 (0)