Fix handling where supplied content-type header is busted.

This commit is contained in:
Andrew McMillan 2011-10-06 11:05:15 +02:00
parent 7b93f913db
commit 0db1fed1de
2 changed files with 9 additions and 3 deletions

View File

@ -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');

View File

@ -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';
}