summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2022-10-21 15:42:27 +0200
committerGitHub <noreply@github.com>2022-10-21 15:42:27 +0200
commit56fe33ffca52e60d93f88367f1119fd7aa1013b8 (patch)
tree91affb4e1bd5f432c52d3d9fc30bc1df6f2552a6 /apps
parent7848d1cab6e0e3a6fb8cd15c4a8cba7147dabab9 (diff)
parent2b4a11598dcd2730123ec208a0066dfb6f2ffed9 (diff)
downloadnextcloud-server-56fe33ffca52e60d93f88367f1119fd7aa1013b8.tar.gz
nextcloud-server-56fe33ffca52e60d93f88367f1119fd7aa1013b8.zip
Merge pull request #34508 from starypatyk/dav_displayname
WebDAV - use file/folder name for dav:displayname
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/lib/Connector/Sabre/FilesPlugin.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/apps/dav/lib/Connector/Sabre/FilesPlugin.php b/apps/dav/lib/Connector/Sabre/FilesPlugin.php
index e9d27d4e7f6..54919824864 100644
--- a/apps/dav/lib/Connector/Sabre/FilesPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/FilesPlugin.php
@@ -71,6 +71,7 @@ class FilesPlugin extends ServerPlugin {
public const GETETAG_PROPERTYNAME = '{DAV:}getetag';
public const LASTMODIFIED_PROPERTYNAME = '{DAV:}lastmodified';
public const CREATIONDATE_PROPERTYNAME = '{DAV:}creationdate';
+ public const DISPLAYNAME_PROPERTYNAME = '{DAV:}displayname';
public const OWNER_ID_PROPERTYNAME = '{http://owncloud.org/ns}owner-id';
public const OWNER_DISPLAY_NAME_PROPERTYNAME = '{http://owncloud.org/ns}owner-display-name';
public const CHECKSUMS_PROPERTYNAME = '{http://owncloud.org/ns}checksums';
@@ -379,6 +380,15 @@ class FilesPlugin extends ServerPlugin {
$propFind->handle(self::CREATION_TIME_PROPERTYNAME, function () use ($node) {
return $node->getFileInfo()->getCreationTime();
});
+ /**
+ * Return file/folder name as displayname. The primary reason to
+ * implement it this way is to avoid costly fallback to
+ * CustomPropertiesBackend (esp. visible when querying all files
+ * in a folder).
+ */
+ $propFind->handle(self::DISPLAYNAME_PROPERTYNAME, function () use ($node) {
+ return $node->getName();
+ });
}
if ($node instanceof \OCA\DAV\Connector\Sabre\File) {
@@ -554,6 +564,13 @@ class FilesPlugin extends ServerPlugin {
$node->setCreationTime((int) $time);
return true;
});
+ /**
+ * Disable modification of the displayname property for files and
+ * folders via PROPPATCH. See PROPFIND for more information.
+ */
+ $propPatch->handle(self::DISPLAYNAME_PROPERTYNAME, function ($displayName) {
+ return 403;
+ });
}
/**