From 999b2b460b1e38a6f01da97fbc6da2c3afd2ddde Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Mon, 25 Nov 2013 14:43:17 +0100 Subject: Ignore If-None-Match: * headers from buggy SOGo connector (#2589) --- lib/Kolab/CardDAV/Plugin.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/Kolab/CardDAV/Plugin.php b/lib/Kolab/CardDAV/Plugin.php index 3d7aa7d..2abf0a8 100644 --- a/lib/Kolab/CardDAV/Plugin.php +++ b/lib/Kolab/CardDAV/Plugin.php @@ -49,11 +49,29 @@ class Plugin extends CardDAV\Plugin { parent::initialize($server); + $server->subscribeEvent('beforeMethod', array($this, 'beforeMethod')); $server->subscribeEvent('afterCreateFile', array($this, 'afterWriteContent')); $server->subscribeEvent('afterWriteContent', array($this, 'afterWriteContent')); } /** + * Handler for beforeMethod events + */ + public function beforeMethod($method, $uri) + { + if ($method == 'PUT' && $this->server->httpRequest->getHeader('If-None-Match') == '*') { + // In-None-Match: * is only valid with PUT requests creating a new resource. + // SOGo Conenctor for Thunderbird also sends it with update requests which then fail + // in the Server::checkPreconditions(). + // See https://issues.kolab.org/show_bug.cgi?id=2589 and http://www.sogo.nu/bugs/view.php?id=1624 + // This is a work-around for the buggy SOGo connector and should be removed once fixed. + if (strpos($this->server->httpRequest->getHeader('User-Agent'), 'Thunderbird/') > 0) { + unset($_SERVER['HTTP_IF_NONE_MATCH']); + } + } + } + + /** * Inject some additional HTTP response headers */ public function afterWriteContent($uri, $node) -- cgit v0.12