From e05ce4d614dc40515427ffd185624b6f8dd60298 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 5 Oct 2011 08:15:24 +0000 Subject: [PATCH] enclosing etag in quotes, as most servers do --- addressbook/inc/class.addressbook_groupdav.inc.php | 4 ++-- calendar/inc/class.calendar_groupdav.inc.php | 7 ++++--- infolog/inc/class.infolog_groupdav.inc.php | 4 ++-- phpgwapi/inc/class.groupdav.inc.php | 5 +++++ phpgwapi/inc/class.groupdav_handler.inc.php | 8 +++++--- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/addressbook/inc/class.addressbook_groupdav.inc.php b/addressbook/inc/class.addressbook_groupdav.inc.php index e8327d63e0..706ddd3820 100644 --- a/addressbook/inc/class.addressbook_groupdav.inc.php +++ b/addressbook/inc/class.addressbook_groupdav.inc.php @@ -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') diff --git a/calendar/inc/class.calendar_groupdav.inc.php b/calendar/inc/class.calendar_groupdav.inc.php index 49b6daaf5f..a34ffb5fe0 100644 --- a/calendar/inc/class.calendar_groupdav.inc.php +++ b/calendar/inc/class.calendar_groupdav.inc.php @@ -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; diff --git a/infolog/inc/class.infolog_groupdav.inc.php b/infolog/inc/class.infolog_groupdav.inc.php index 3ee60b1c1c..601ff2206a 100644 --- a/infolog/inc/class.infolog_groupdav.inc.php +++ b/infolog/inc/class.infolog_groupdav.inc.php @@ -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') diff --git a/phpgwapi/inc/class.groupdav.inc.php b/phpgwapi/inc/class.groupdav.inc.php index c5f6e5a4d2..5e6e48e77e 100644 --- a/phpgwapi/inc/class.groupdav.inc.php +++ b/phpgwapi/inc/class.groupdav.inc.php @@ -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( diff --git a/phpgwapi/inc/class.groupdav_handler.inc.php b/phpgwapi/inc/class.groupdav_handler.inc.php index 3e2fda8392..13be045973 100644 --- a/phpgwapi/inc/class.groupdav_handler.inc.php +++ b/phpgwapi/inc/class.groupdav_handler.inc.php @@ -276,15 +276,17 @@ abstract class groupdav_handler // 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) { - $this->http_if_match = $_SERVER['HTTP_IF_MATCH']; 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'])) {