From 74bd2d311c2c910ad22aad40007887719b094cf3 Mon Sep 17 00:00:00 2001 From: Michael Stilkerich Date: Wed, 15 Jul 2020 19:53:00 +0200 Subject: [PATCH 1/3] RFC 4918 compliance: Remove unexpected propstat According to RFC 4918, there is two types of response elements: Type 1 contains one or more href and one status child elements. Type 2 contains one href and one or more propstat child elements. Both types may contain further optional elements. For Type 1, sabre/dav inserts a spurious propstat element, which violated the element definition by RFC 4918. --- lib/DAV/Xml/Element/Response.php | 4 +++- tests/Sabre/DAVACL/PrincipalMatchTest.php | 4 ---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/DAV/Xml/Element/Response.php b/lib/DAV/Xml/Element/Response.php index 45c161fa4f..f03f31872d 100644 --- a/lib/DAV/Xml/Element/Response.php +++ b/lib/DAV/Xml/Element/Response.php @@ -112,12 +112,14 @@ public function getResponseProperties() */ public function xmlSerialize(Writer $writer) { + $empty = true; + if ($status = $this->getHTTPStatus()) { + $empty = false; $writer->writeElement('{DAV:}status', 'HTTP/1.1 '.$status.' '.\Sabre\HTTP\Response::$statusCodes[$status]); } $writer->writeElement('{DAV:}href', $writer->contextUri.\Sabre\HTTP\encodePath($this->getHref())); - $empty = true; foreach ($this->getResponseProperties() as $status => $properties) { // Skipping empty lists diff --git a/tests/Sabre/DAVACL/PrincipalMatchTest.php b/tests/Sabre/DAVACL/PrincipalMatchTest.php index 0746d2e50e..7862f2c59d 100644 --- a/tests/Sabre/DAVACL/PrincipalMatchTest.php +++ b/tests/Sabre/DAVACL/PrincipalMatchTest.php @@ -30,10 +30,6 @@ public function testPrincipalMatch() HTTP/1.1 200 OK /principals/user1 - - - HTTP/1.1 418 I'm a teapot - XML; From facb0993209b56a530f4f9a9af2ea1c88903c328 Mon Sep 17 00:00:00 2001 From: Michael Stilkerich Date: Wed, 22 Jul 2020 20:15:41 +0200 Subject: [PATCH 2/3] Remove an empty line that phpstan rejected --- lib/DAV/Xml/Element/Response.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/DAV/Xml/Element/Response.php b/lib/DAV/Xml/Element/Response.php index f03f31872d..5a4834e230 100644 --- a/lib/DAV/Xml/Element/Response.php +++ b/lib/DAV/Xml/Element/Response.php @@ -120,7 +120,6 @@ public function xmlSerialize(Writer $writer) } $writer->writeElement('{DAV:}href', $writer->contextUri.\Sabre\HTTP\encodePath($this->getHref())); - foreach ($this->getResponseProperties() as $status => $properties) { // Skipping empty lists if (!$properties || (!ctype_digit($status) && !is_int($status))) { From 1eeecce4fd8274886eb2e6ab361f74cbba0e4da7 Mon Sep 17 00:00:00 2001 From: Michael Stilkerich Date: Fri, 22 Jan 2021 16:58:33 +0100 Subject: [PATCH 3/3] Fix null dereference error in param-filter --- lib/CardDAV/Plugin.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/CardDAV/Plugin.php b/lib/CardDAV/Plugin.php index 09d1f593da..7097c8569b 100644 --- a/lib/CardDAV/Plugin.php +++ b/lib/CardDAV/Plugin.php @@ -587,7 +587,14 @@ protected function validateParamFilters(array $vProperties, array $filters, $tes foreach ($vProperties as $vProperty) { // If we got all the way here, we'll need to validate the // text-match filter. - $success = DAV\StringUtil::textMatch($vProperty[$filter['name']]->getValue(), $filter['text-match']['value'], $filter['text-match']['collation'], $filter['text-match']['match-type']); + if (isset($vProperty[$filter['name']])) { + $success = DAV\StringUtil::textMatch( + $vProperty[$filter['name']]->getValue(), + $filter['text-match']['value'], + $filter['text-match']['collation'], + $filter['text-match']['match-type'] + ); + } if ($success) { break; }