diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2021-02-17 10:48:25 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-17 10:48:25 +0300 |
commit | fb2b19221f8bdd16ed1059e0edcf9de7a35d2693 (patch) | |
tree | 1fec757f2927bb0ae6990cd07cf687533a393d10 /apps/dav | |
parent | fab7d9ca5fd9bbc8ffce9d136e1649f3434dd812 (diff) | |
parent | ae8903e946c4664b6df699769a497a4d290cd200 (diff) |
Merge pull request #25385 from nextcloud/backport/25218/stable19
[stable19] do not remove valid group shares
Diffstat (limited to 'apps/dav')
-rw-r--r-- | apps/dav/lib/Connector/Sabre/Principal.php | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/apps/dav/lib/Connector/Sabre/Principal.php b/apps/dav/lib/Connector/Sabre/Principal.php index 5dedb0a7d7b..09f369b8f9e 100644 --- a/apps/dav/lib/Connector/Sabre/Principal.php +++ b/apps/dav/lib/Connector/Sabre/Principal.php @@ -40,6 +40,7 @@ use OCA\DAV\Traits\PrincipalProxyTrait; use OCP\App\IAppManager; use OCP\AppFramework\QueryException; use OCP\IConfig; +use OCP\IGroup; use OCP\IGroupManager; use OCP\IUser; use OCP\IUserManager; @@ -151,6 +152,7 @@ class Principal implements BackendInterface { */ public function getPrincipalByPath($path) { list($prefix, $name) = \Sabre\Uri\split($path); + $decodedName = urldecode($name); if ($name === 'calendar-proxy-write' || $name === 'calendar-proxy-read') { list($prefix2, $name2) = \Sabre\Uri\split($prefix); @@ -172,14 +174,28 @@ class Principal implements BackendInterface { // is called either with a urlencoded version of the name or with a non-urlencoded one. // The urldecode function replaces %## and +, both of which are forbidden in usernames. // Hence there can be no ambiguity here and it is safe to call urldecode on all usernames - $user = $this->userManager->get(urldecode($name)); + $user = $this->userManager->get($decodedName); if ($user !== null) { return $this->userToPrincipal($user); } } elseif ($prefix === 'principals/circles') { if ($this->userSession->getUser() !== null) { - return $this->circleToPrincipal($name); + // At the time of writing - 2021-01-19 — a mixed state is possible. + // The second condition can be removed when this is fixed. + return $this->circleToPrincipal($decodedName) + ?: $this->circleToPrincipal($name); + } + } elseif ($prefix === 'principals/groups') { + // At the time of writing - 2021-01-19 — a mixed state is possible. + // The second condition can be removed when this is fixed. + $group = $this->groupManager->get($decodedName) + ?: $this->groupManager->get($name); + if ($group instanceof IGroup) { + return [ + 'uri' => 'principals/groups/' . $name, + '{DAV:}displayname' => $group->getDisplayName(), + ]; } } return null; |