From a88fbb756f98e323ed67953cc6f6a2efb4d56437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Lehrke?= Date: Mon, 14 Jun 2010 07:38:41 +0000 Subject: [PATCH] 2nd Fix Evolution CalDAV HTTP_IF_MATCH issue (Stylite#601) --- phpgwapi/inc/class.groupdav_handler.inc.php | 30 ++++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/phpgwapi/inc/class.groupdav_handler.inc.php b/phpgwapi/inc/class.groupdav_handler.inc.php index c16e6b326c..c79489f6c2 100644 --- a/phpgwapi/inc/class.groupdav_handler.inc.php +++ b/phpgwapi/inc/class.groupdav_handler.inc.php @@ -267,19 +267,29 @@ abstract class groupdav_handler $etag = $this->get_etag($entry); // 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']) && - ($this->http_if_match = (strstr($_SERVER['HTTP_IF_MATCH'], $etag) === false))) + if (isset($_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'; + if (strstr($_SERVER['HTTP_IF_MATCH'], $etag) === false) + { + $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'])) + { + if ($this->debug) error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 304 Not Modified"); + return '304 Not Modified'; + } + } } - // 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']) && - strstr($_SERVER['HTTP_IF_MATCH'], $etag) !== false) + if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) { - if ($this->debug) error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 304 Not Modified"); - return '304 Not Modified'; + if ($this->debug) error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 412 Precondition failed"); + return '412 Precondition Failed'; } } return $entry;