From 0db1fed1dec6941a7e71473d251ccbbd1d9b9f9f Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Thu, 6 Oct 2011 11:05:15 +0200 Subject: [PATCH] Fix handling where supplied content-type header is busted. --- htdocs/caldav.php | 1 - inc/CalDAVRequest.php | 11 +++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/caldav.php b/htdocs/caldav.php index a44ab79b..2083fb6f 100644 --- a/htdocs/caldav.php +++ b/htdocs/caldav.php @@ -110,7 +110,6 @@ switch ( $request->method ) { case 'HEAD': include('caldav-GET.php'); break; case 'PROPPATCH': include('caldav-PROPPATCH.php'); break; case 'PUT': - $request->CoerceContentType(); switch( $request->content_type ) { case 'text/calendar': include('caldav-PUT-vcalendar.php'); diff --git a/inc/CalDAVRequest.php b/inc/CalDAVRequest.php index 4ee230fd..1eecbec0 100644 --- a/inc/CalDAVRequest.php +++ b/inc/CalDAVRequest.php @@ -162,6 +162,9 @@ class CalDAVRequest $this->content_type = 'text/xml'; } } + else if ( $this->method == 'PUT' || $this->method == 'POST' ) { + $this->CoerceContentType(); + } } $this->user_agent = ((isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "Probably Mulberry")); @@ -840,7 +843,11 @@ EOSQL; if ( isset($this->content_type) ) { $type = explode( '/', $this->content_type, 2); /** @todo: Perhaps we should look at the target collection type, also. */ - if ( $type[0] == 'text' ) return; + if ( $type[0] == 'text' ) { + if ( !empty($type[2]) && ($type[2] == 'vcard' || $type[2] == 'calendar' || $type[2] == 'x-vcard') ) { + return; + } + } } /** Null (or peculiar) content-type supplied so we have to try and work it out... */ @@ -866,7 +873,7 @@ EOSQL; dbg_error_log( 'LOG NOTICE', 'Unusual content-type of "%s" and first word of content is "%s"', (isset($this->content_type)?$this->content_type:'(null)'), $first_word ); } - $this->content_type = 'text/plain'; + if ( empty($this->content_type) ) $this->content_type = 'text/plain'; }