Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable20] do not remove valid group shares #25384

Merged
merged 1 commit into from
Feb 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions apps/dav/lib/Connector/Sabre/Principal.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
use OCP\App\IAppManager;
use OCP\AppFramework\QueryException;
use OCP\IConfig;
use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserManager;
Expand Down Expand Up @@ -151,6 +152,7 @@ public function getPrincipalsByPrefix($prefixPath) {
*/
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);
Expand All @@ -172,14 +174,28 @@ public function getPrincipalByPath($path) {
// 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;
Expand Down