Skip to content

Commit bf61a43

Browse files
blizzzrullzer
authored andcommitted
do not remove valid group shares
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
1 parent 39a6ab6 commit bf61a43

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

apps/dav/lib/Connector/Sabre/Principal.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
use OCP\App\IAppManager;
4141
use OCP\AppFramework\QueryException;
4242
use OCP\IConfig;
43+
use OCP\IGroup;
4344
use OCP\IGroupManager;
4445
use OCP\IUser;
4546
use OCP\IUserManager;
@@ -151,6 +152,7 @@ public function getPrincipalsByPrefix($prefixPath) {
151152
*/
152153
public function getPrincipalByPath($path) {
153154
list($prefix, $name) = \Sabre\Uri\split($path);
155+
$decodedName = urldecode($name);
154156

155157
if ($name === 'calendar-proxy-write' || $name === 'calendar-proxy-read') {
156158
list($prefix2, $name2) = \Sabre\Uri\split($prefix);
@@ -172,14 +174,28 @@ public function getPrincipalByPath($path) {
172174
// is called either with a urlencoded version of the name or with a non-urlencoded one.
173175
// The urldecode function replaces %## and +, both of which are forbidden in usernames.
174176
// Hence there can be no ambiguity here and it is safe to call urldecode on all usernames
175-
$user = $this->userManager->get(urldecode($name));
177+
$user = $this->userManager->get($decodedName);
176178

177179
if ($user !== null) {
178180
return $this->userToPrincipal($user);
179181
}
180182
} elseif ($prefix === 'principals/circles') {
181183
if ($this->userSession->getUser() !== null) {
182-
return $this->circleToPrincipal($name);
184+
// At the time of writing - 2021-01-19 — a mixed state is possible.
185+
// The second condition can be removed when this is fixed.
186+
return $this->circleToPrincipal($decodedName)
187+
?: $this->circleToPrincipal($name);
188+
}
189+
} elseif ($prefix === 'principals/groups') {
190+
// At the time of writing - 2021-01-19 — a mixed state is possible.
191+
// The second condition can be removed when this is fixed.
192+
$group = $this->groupManager->get($decodedName)
193+
?: $this->groupManager->get($name);
194+
if ($group instanceof IGroup) {
195+
return [
196+
'uri' => 'principals/groups/' . $name,
197+
'{DAV:}displayname' => $group->getDisplayName(),
198+
];
183199
}
184200
}
185201
return null;

0 commit comments

Comments
 (0)