diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2023-06-22 09:02:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-22 09:02:55 +0200 |
commit | e9d8dbf53c76670e84bee1c74630e09aca5d7d77 (patch) | |
tree | 5372dd8698d7ad75061f94a8cfb033217471ace6 /apps/dav | |
parent | 44850c27a067972f1982f9d36fb9dcf50d39293c (diff) | |
parent | debd03f30d236e28fe7952dde517acb132f7c095 (diff) | |
download | nextcloud-server-e9d8dbf53c76670e84bee1c74630e09aca5d7d77.tar.gz nextcloud-server-e9d8dbf53c76670e84bee1c74630e09aca5d7d77.zip |
Merge pull request #38747 from nextcloud/perf/early-exit-mkcol
perf: skip request without write permission
Diffstat (limited to 'apps/dav')
-rw-r--r-- | apps/dav/lib/Connector/Sabre/DavAclPlugin.php | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/apps/dav/lib/Connector/Sabre/DavAclPlugin.php b/apps/dav/lib/Connector/Sabre/DavAclPlugin.php index 6842975835d..7fa94d7b903 100644 --- a/apps/dav/lib/Connector/Sabre/DavAclPlugin.php +++ b/apps/dav/lib/Connector/Sabre/DavAclPlugin.php @@ -94,8 +94,19 @@ class DavAclPlugin extends \Sabre\DAVACL\Plugin { $path = $request->getPath(); // prevent the plugin from causing an unneeded overhead for file requests - if (strpos($path, 'files/') !== 0) { - parent::beforeMethod($request, $response); + if (str_starts_with($path, 'files/')) { + return; + } + + parent::beforeMethod($request, $response); + + $createAddressbookOrCalendarRequest = ($request->getMethod() === 'MKCALENDAR' || $request->getMethod() === 'MKCOL') + && (str_starts_with($path, 'addressbooks/') || str_starts_with($path, 'calendars/')); + + if ($createAddressbookOrCalendarRequest) { + [$parentName] = \Sabre\Uri\split($path); + // is calendars/users/bob or addressbooks/users/bob writeable? + $this->checkPrivileges($parentName, '{DAV:}write'); } } } |