diff options
author | Christoph Wurst <ChristophWurst@users.noreply.github.com> | 2021-01-29 11:36:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-29 11:36:28 +0100 |
commit | 65b6b4597685c2b097a8690cc9fe424bcefd4649 (patch) | |
tree | 0731561a3bc451e1d54d3593df0d8741f7874392 /apps/dav/lib | |
parent | 6a3321cefeacb977e2832e26e28d72a6223d6b48 (diff) | |
parent | fcade3dda3f82a68ba7fda09f625bcc69a2550c6 (diff) | |
download | nextcloud-server-65b6b4597685c2b097a8690cc9fe424bcefd4649.tar.gz nextcloud-server-65b6b4597685c2b097a8690cc9fe424bcefd4649.zip |
Merge pull request #25218 from nextcloud/fix/25213/do-no-remove-vali-dav-group-shares
do not remove valid group shares
Diffstat (limited to 'apps/dav/lib')
-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 55b63df8c67..c1b1dc1b2d1 100644 --- a/apps/dav/lib/Connector/Sabre/Principal.php +++ b/apps/dav/lib/Connector/Sabre/Principal.php @@ -43,6 +43,7 @@ use OCP\App\IAppManager; use OCP\AppFramework\QueryException; use OCP\Constants; use OCP\IConfig; +use OCP\IGroup; use OCP\IGroupManager; use OCP\IUser; use OCP\IUserManager; @@ -154,6 +155,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); @@ -175,14 +177,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; |