enclosing etag in quotes, as most servers do

This commit is contained in:
Ralf Becker 2011-10-05 08:15:24 +00:00
parent bedafe6c79
commit e05ce4d614
5 changed files with 18 additions and 10 deletions

View File

@ -387,7 +387,7 @@ class addressbook_groupdav extends groupdav_handler
// e.g. Evolution does not understand 'text/vcard'
$options['mimetype'] = 'text/x-vcard; charset='.$this->charset;
header('Content-Encoding: identity');
header('ETag: '.$this->get_etag($contact));
header('ETag: "'.$this->get_etag($contact).'"');
return true;
}
@ -499,7 +499,7 @@ class addressbook_groupdav extends groupdav_handler
}
// we should not return an etag here, as we never store the PUT vcard byte-by-byte
//header('ETag: '.$this->get_etag($contact));
//header('ETag: "'.$this->get_etag($contact).'"');
// send GroupDAV Location header only if we dont use carddav_name as path-attribute
if ($retval !== true && self::$path_attr == 'id')

View File

@ -391,7 +391,7 @@ class calendar_groupdav extends groupdav_handler
$options['data'] = $this->iCal($event, $user, strpos($options['path'], '/inbox/') !== false ? 'PUBLISH' : null);
$options['mimetype'] = 'text/calendar; charset=utf-8';
header('Content-Encoding: identity');
header('ETag: '.$this->get_etag($event));
header('ETag: "'.$this->get_etag($event).'"');
return true;
}
@ -598,7 +598,7 @@ class calendar_groupdav extends groupdav_handler
}
// we should not return an etag here, as we never store the PUT ical byte-by-byte
//header('ETag: '.$this->get_etag($cal_id));
//header('ETag: "'.$this->get_etag($cal_id).'"');
// send GroupDAV Location header only if we dont use caldav_name as path-attribute
if ($retval !== true && self::$path_attr != 'caldav_name')
@ -677,7 +677,8 @@ class calendar_groupdav extends groupdav_handler
{
if ($this->debug) error_log(__METHOD__."() importVCal($eventId) returned false");
}
header('ETag: '.$this->get_etag($eventId));
// we should not return an etag here, as we never store the ical byte-by-byte
//header('ETag: "'.$this->get_etag($eventId).'"');
}
}
return true;

View File

@ -361,7 +361,7 @@ class infolog_groupdav extends groupdav_handler
$options['data'] = $handler->exportVTODO($task, '2.0', null); // no METHOD:PUBLISH for CalDAV
$options['mimetype'] = 'text/calendar; charset=utf-8';
header('Content-Encoding: identity');
header('ETag: '.$this->get_etag($task));
header('ETag: "'.$this->get_etag($task).'"');
return true;
}
@ -432,7 +432,7 @@ class infolog_groupdav extends groupdav_handler
}
// we should not return an etag here, as we never store the PUT ical byte-by-byte
//header('ETag: '.$this->get_etag($infoId));
//header('ETag: "'.$this->get_etag($infoId).'"');
// send GroupDAV Location header only if we dont use caldav_name as path-attribute
if ($retval !== true && self::$path_attr != 'caldav_name')

View File

@ -460,6 +460,11 @@ class groupdav extends HTTP_WebDAV_Server
{
$prop = self::mkprop($name, $prop);
}
// add quotes around etag, if they are not already there
if ($prop['name'] == 'getetag' && $prop['val'][0] != '"')
{
$prop['val'] = '"'.$prop['val'].'"';
}
}
return array(

View File

@ -275,16 +275,18 @@ abstract class groupdav_handler
// If the clients sends an "If-Match" header ($_SERVER['HTTP_IF_MATCH']) we check with the current etag
// of the calendar --> on failure we return 412 Precondition failed, to not overwrite the modifications
if (isset($_SERVER['HTTP_IF_MATCH']))
{
if (strstr($_SERVER['HTTP_IF_MATCH'], $etag) === false)
{
$this->http_if_match = $_SERVER['HTTP_IF_MATCH'];
// strip of quotes around etag, if they exist, that way we allow etag with and without quotes
if ($this->http_if_match[0] == '"') $this->http_if_match = substr($this->http_if_match, 1, -1);
if ($this->http_if_match !== $etag)
{
if ($this->debug) error_log(__METHOD__."($method,,$id) HTTP_IF_MATCH='$_SERVER[HTTP_IF_MATCH]', etag='$etag': 412 Precondition failed");
return '412 Precondition Failed';
}
else
{
$this->http_if_match = $etag;
// if an IF_NONE_MATCH is given, check if we need to send a new export, or the current one is still up-to-date
if ($method == 'GET' && isset($_SERVER['HTTP_IF_NONE_MATCH']))
{