aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/lib/DAV
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/dav/lib/DAV')
-rw-r--r--vendor/sabre/dav/lib/DAV/Client.php108
-rw-r--r--vendor/sabre/dav/lib/DAV/INodeByPath.php36
-rw-r--r--vendor/sabre/dav/lib/DAV/Sync/ISyncCollection.php2
-rw-r--r--vendor/sabre/dav/lib/DAV/Tree.php30
-rw-r--r--vendor/sabre/dav/lib/DAV/Version.php2
-rw-r--r--vendor/sabre/dav/lib/DAV/Xml/Element/Response.php46
-rw-r--r--vendor/sabre/dav/lib/DAV/Xml/Property/Href.php13
7 files changed, 181 insertions, 56 deletions
diff --git a/vendor/sabre/dav/lib/DAV/Client.php b/vendor/sabre/dav/lib/DAV/Client.php
index a9de71cdb..1028a6b9d 100644
--- a/vendor/sabre/dav/lib/DAV/Client.php
+++ b/vendor/sabre/dav/lib/DAV/Client.php
@@ -174,27 +174,98 @@ class Client extends HTTP\Client
}
/**
- * Does a PROPFIND request.
+ * Does a PROPFIND request with filtered response returning only available properties.
*
* The list of requested properties must be specified as an array, in clark
* notation.
*
- * The returned array will contain a list of filenames as keys, and
- * properties as values.
+ * Depth should be either 0 or 1. A depth of 1 will cause a request to be
+ * made to the server to also return all child resources.
+ *
+ * For depth 0, just the array of properties for the resource is returned.
+ *
+ * For depth 1, the returned array will contain a list of resource names as keys,
+ * and an array of properties as values.
*
- * The properties array will contain the list of properties. Only properties
- * that are actually returned from the server (without error) will be
+ * The array of properties will contain the properties as keys with their values as the value.
+ * Only properties that are actually returned from the server without error will be
* returned, anything else is discarded.
*
+ * @param 1|0 $depth
+ */
+ public function propFind($url, array $properties, $depth = 0): array
+ {
+ $result = $this->doPropFind($url, $properties, $depth);
+
+ // If depth was 0, we only return the top item
+ if (0 === $depth) {
+ reset($result);
+ $result = current($result);
+
+ return isset($result[200]) ? $result[200] : [];
+ }
+
+ $newResult = [];
+ foreach ($result as $href => $statusList) {
+ $newResult[$href] = isset($statusList[200]) ? $statusList[200] : [];
+ }
+
+ return $newResult;
+ }
+
+ /**
+ * Does a PROPFIND request with unfiltered response.
+ *
+ * The list of requested properties must be specified as an array, in clark
+ * notation.
+ *
* Depth should be either 0 or 1. A depth of 1 will cause a request to be
* made to the server to also return all child resources.
*
- * @param string $url
- * @param int $depth
+ * For depth 0, just the multi-level array of status and properties for the resource is returned.
*
- * @return array
+ * For depth 1, the returned array will contain a list of resources as keys and
+ * a multi-level array containing status and properties as value.
+ *
+ * The multi-level array of status and properties is formatted the same as what is
+ * documented for parseMultiStatus.
+ *
+ * All properties that are actually returned from the server are returned by this method.
+ *
+ * @param 1|0 $depth
+ */
+ public function propFindUnfiltered(string $url, array $properties, int $depth = 0): array
+ {
+ $result = $this->doPropFind($url, $properties, $depth);
+
+ // If depth was 0, we only return the top item
+ if (0 === $depth) {
+ reset($result);
+
+ return current($result);
+ } else {
+ return $result;
+ }
+ }
+
+ /**
+ * Does a PROPFIND request.
+ *
+ * The list of requested properties must be specified as an array, in clark
+ * notation.
+ *
+ * Depth should be either 0 or 1. A depth of 1 will cause a request to be
+ * made to the server to also return all child resources.
+ *
+ * The returned array will contain a list of resources as keys and
+ * a multi-level array containing status and properties as value.
+ *
+ * The multi-level array of status and properties is formatted the same as what is
+ * documented for parseMultiStatus.
+ *
+ * @param 1|0 $depth
*/
- public function propFind($url, array $properties, $depth = 0)
+ private function doPropFind($url, array $properties, $depth = 0): array
{
$dom = new \DOMDocument('1.0', 'UTF-8');
$dom->formatOutput = true;
@@ -232,22 +303,7 @@ class Client extends HTTP\Client
throw new HTTP\ClientHttpException($response);
}
- $result = $this->parseMultiStatus($response->getBodyAsString());
-
- // If depth was 0, we only return the top item
- if (0 === $depth) {
- reset($result);
- $result = current($result);
-
- return isset($result[200]) ? $result[200] : [];
- }
-
- $newResult = [];
- foreach ($result as $href => $statusList) {
- $newResult[$href] = isset($statusList[200]) ? $statusList[200] : [];
- }
-
- return $newResult;
+ return $this->parseMultiStatus($response->getBodyAsString());
}
/**
@@ -385,7 +441,7 @@ class Client extends HTTP\Client
{
return Uri\resolve(
$this->baseUri,
- $url
+ (string) $url
);
}
diff --git a/vendor/sabre/dav/lib/DAV/INodeByPath.php b/vendor/sabre/dav/lib/DAV/INodeByPath.php
new file mode 100644
index 000000000..4d63a33bd
--- /dev/null
+++ b/vendor/sabre/dav/lib/DAV/INodeByPath.php
@@ -0,0 +1,36 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Sabre\DAV;
+
+/**
+ * INodeByPath.
+ *
+ * This interface adds a tiny bit of functionality to collections.
+ *
+ * Getting a node that is deep in the tree normally requires going trough each parent node
+ * which can cause a significant performance overhead.
+ *
+ * Implementing this interface allows solving this overhead by directly jumping to the target node.
+ *
+ * @copyright Copyright (C) Robin Appelman (https://icewind.nl/)
+ * @author Robin Appelman (https://icewind.nl/)
+ * @license http://sabre.io/license/ Modified BSD License
+ */
+interface INodeByPath
+{
+ /**
+ * Returns the INode object for the requested path.
+ *
+ * In case where this collection can not retrieve the requested node
+ * but also can not determine that the node does not exists,
+ * null should be returned to signal that the caller should fallback
+ * to walking the directory tree.
+ *
+ * @param string $path
+ *
+ * @return INode|null
+ */
+ public function getNodeForPath($path);
+}
diff --git a/vendor/sabre/dav/lib/DAV/Sync/ISyncCollection.php b/vendor/sabre/dav/lib/DAV/Sync/ISyncCollection.php
index 4ca69dc89..c829716b7 100644
--- a/vendor/sabre/dav/lib/DAV/Sync/ISyncCollection.php
+++ b/vendor/sabre/dav/lib/DAV/Sync/ISyncCollection.php
@@ -84,7 +84,7 @@ interface ISyncCollection extends DAV\ICollection
* @param int $syncLevel
* @param int $limit
*
- * @return array
+ * @return array|null
*/
public function getChanges($syncToken, $syncLevel, $limit = null);
}
diff --git a/vendor/sabre/dav/lib/DAV/Tree.php b/vendor/sabre/dav/lib/DAV/Tree.php
index 8215e2c39..65b4583ce 100644
--- a/vendor/sabre/dav/lib/DAV/Tree.php
+++ b/vendor/sabre/dav/lib/DAV/Tree.php
@@ -16,7 +16,7 @@ use Sabre\Uri;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class Tree
+class Tree implements INodeByPath
{
/**
* The root node.
@@ -62,20 +62,26 @@ class Tree
return $this->rootNode;
}
- // Attempting to fetch its parent
- list($parentName, $baseName) = Uri\split($path);
+ $parts = explode('/', $path);
+ $node = $this->rootNode;
- // If there was no parent, we must simply ask it from the root node.
- if ('' === $parentName) {
- $node = $this->rootNode->getChild($baseName);
- } else {
- // Otherwise, we recursively grab the parent and ask him/her.
- $parent = $this->getNodeForPath($parentName);
-
- if (!($parent instanceof ICollection)) {
+ while (count($parts)) {
+ if (!($node instanceof ICollection)) {
throw new Exception\NotFound('Could not find node at path: '.$path);
}
- $node = $parent->getChild($baseName);
+
+ if ($node instanceof INodeByPath) {
+ $targetNode = $node->getNodeForPath(implode('/', $parts));
+ if ($targetNode instanceof Node) {
+ $node = $targetNode;
+ break;
+ }
+ }
+
+ $part = array_shift($parts);
+ if ('' !== $part) {
+ $node = $node->getChild($part);
+ }
}
$this->cache[$path] = $node;
diff --git a/vendor/sabre/dav/lib/DAV/Version.php b/vendor/sabre/dav/lib/DAV/Version.php
index c6273ef72..345c62d7e 100644
--- a/vendor/sabre/dav/lib/DAV/Version.php
+++ b/vendor/sabre/dav/lib/DAV/Version.php
@@ -16,5 +16,5 @@ class Version
/**
* Full version number.
*/
- public const VERSION = '4.4.0';
+ public const VERSION = '4.6.0';
}
diff --git a/vendor/sabre/dav/lib/DAV/Xml/Element/Response.php b/vendor/sabre/dav/lib/DAV/Xml/Element/Response.php
index 79f06a09b..df9291465 100644
--- a/vendor/sabre/dav/lib/DAV/Xml/Element/Response.php
+++ b/vendor/sabre/dav/lib/DAV/Xml/Element/Response.php
@@ -40,7 +40,7 @@ class Response implements Element
*
* This is currently only used in WebDAV-Sync
*
- * @var string
+ * @var string|null
*/
protected $httpStatus;
@@ -112,13 +112,21 @@ class Response implements Element
*/
public function xmlSerialize(Writer $writer)
{
- if ($status = $this->getHTTPStatus()) {
- $writer->writeElement('{DAV:}status', 'HTTP/1.1 '.$status.' '.\Sabre\HTTP\Response::$statusCodes[$status]);
- }
+ /*
+ * Accordingly to the RFC the element looks like:
+ * <!ELEMENT response (href, ((href*, status)|(propstat+)), error?, responsedescription? , location?) >
+ *
+ * So the response
+ * - MUST contain a href and
+ * - EITHER a status and additional href(s)
+ * OR one or more propstat(s)
+ */
$writer->writeElement('{DAV:}href', $writer->contextUri.\Sabre\HTTP\encodePath($this->getHref()));
$empty = true;
+ $httpStatus = $this->getHTTPStatus();
+ // Add propstat elements
foreach ($this->getResponseProperties() as $status => $properties) {
// Skipping empty lists
if (!$properties || (!is_int($status) && !ctype_digit($status))) {
@@ -130,19 +138,25 @@ class Response implements Element
$writer->writeElement('{DAV:}status', 'HTTP/1.1 '.$status.' '.\Sabre\HTTP\Response::$statusCodes[$status]);
$writer->endElement(); // {DAV:}propstat
}
+
+ // The WebDAV spec only allows the status element on responses _without_ a propstat
if ($empty) {
- /*
- * The WebDAV spec _requires_ at least one DAV:propstat to appear for
- * every DAV:response. In some circumstances however, there are no
- * properties to encode.
- *
- * In those cases we MUST specify at least one DAV:propstat anyway, with
- * no properties.
- */
- $writer->writeElement('{DAV:}propstat', [
- '{DAV:}prop' => [],
- '{DAV:}status' => 'HTTP/1.1 418 '.\Sabre\HTTP\Response::$statusCodes[418],
- ]);
+ if (null !== $httpStatus) {
+ $writer->writeElement('{DAV:}status', 'HTTP/1.1 '.$httpStatus.' '.\Sabre\HTTP\Response::$statusCodes[$httpStatus]);
+ } else {
+ /*
+ * The WebDAV spec _requires_ at least one DAV:propstat to appear for
+ * every DAV:response if there is no status.
+ * In some circumstances however, there are no properties to encode.
+ *
+ * In those cases we MUST specify at least one DAV:propstat anyway, with
+ * no properties.
+ */
+ $writer->writeElement('{DAV:}propstat', [
+ '{DAV:}prop' => [],
+ '{DAV:}status' => 'HTTP/1.1 418 '.\Sabre\HTTP\Response::$statusCodes[418],
+ ]);
+ }
}
}
diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/Href.php b/vendor/sabre/dav/lib/DAV/Xml/Property/Href.php
index f88ce814a..d4e43da7c 100644
--- a/vendor/sabre/dav/lib/DAV/Xml/Property/Href.php
+++ b/vendor/sabre/dav/lib/DAV/Xml/Property/Href.php
@@ -35,6 +35,19 @@ class Href implements Element, HtmlOutput
protected $hrefs;
/**
+ * Automatically prefix the url with the server base directory.
+ * Note: use of this property in code was removed in PR:
+ * https://github.com/sabre-io/dav/pull/801
+ * But the property is left here because old data may still exist
+ * that has this property saved.
+ * See discussion in issue:
+ * https://github.com/sabre-io/Baikal/issues/1154.
+ *
+ * @var bool
+ */
+ protected $autoPrefix = true;
+
+ /**
* Constructor.
*
* You must either pass a string for a single href, or an array of hrefs.