From c36874ea146550e1f85490c8591f3051973971b0 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Tue, 31 Jul 2007 07:40:06 +1200 Subject: [PATCH] Per RFC2518 the Depth header should have varying default values. --- inc/CalDAVRequest.php | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/inc/CalDAVRequest.php b/inc/CalDAVRequest.php index bd4e09e5..1f68b275 100644 --- a/inc/CalDAVRequest.php +++ b/inc/CalDAVRequest.php @@ -45,7 +45,29 @@ class CalDAVRequest /** * A variety of requests may set the "Depth" header to control recursion */ - $this->depth = ( isset($_SERVER['HTTP_DEPTH']) ? $_SERVER['HTTP_DEPTH'] : 0 ); + if ( isset($_SERVER['HTTP_DEPTH']) ) { + $this->depth = $_SERVER['HTTP_DEPTH']; + } + else { + /** + * Per rfc2518, section 9.2, 'Depth' might not always be present, and if it + * is not present then a reasonable request-type-dependent default should be + * chosen. + */ + switch( $this->method ) { + case 'PROPFIND': + case 'DELETE': + case 'MOVE': + case 'COPY': + case 'LOCK': + $this->depth = 'infinity'; + break; + + case 'REPORT': + default: + $this->depth = 0; + } + } if ( $this->depth == 'infinity' ) $this->depth = DEPTH_INFINITY; $this->depth = intval($this->depth); @@ -458,7 +480,7 @@ class CalDAVRequest /** * Send an XML Response. This function will never return. - * + * * @param int $status The HTTP status to respond * @param XMLElement $xmltree An XMLElement tree to be rendered */ @@ -466,7 +488,7 @@ class CalDAVRequest $xmldoc = $xmltree->Render(0,''); $etag = md5($xmldoc); header("ETag: \"$etag\""); - $this->DoResponse( $status, $xmldoc, 'text/xml; charset="utf-8"' ); + $this->DoResponse( $status, $xmldoc, 'text/xml; charset="utf-8"' ); exit(0); // Unecessary, but might clarify things }