do not remove valid group shares
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
39a6ab6b42
commit
bf61a439d8
|
@ -40,6 +40,7 @@ use OCA\DAV\Traits\PrincipalProxyTrait;
|
||||||
use OCP\App\IAppManager;
|
use OCP\App\IAppManager;
|
||||||
use OCP\AppFramework\QueryException;
|
use OCP\AppFramework\QueryException;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
|
use OCP\IGroup;
|
||||||
use OCP\IGroupManager;
|
use OCP\IGroupManager;
|
||||||
use OCP\IUser;
|
use OCP\IUser;
|
||||||
use OCP\IUserManager;
|
use OCP\IUserManager;
|
||||||
|
@ -151,6 +152,7 @@ class Principal implements BackendInterface {
|
||||||
*/
|
*/
|
||||||
public function getPrincipalByPath($path) {
|
public function getPrincipalByPath($path) {
|
||||||
list($prefix, $name) = \Sabre\Uri\split($path);
|
list($prefix, $name) = \Sabre\Uri\split($path);
|
||||||
|
$decodedName = urldecode($name);
|
||||||
|
|
||||||
if ($name === 'calendar-proxy-write' || $name === 'calendar-proxy-read') {
|
if ($name === 'calendar-proxy-write' || $name === 'calendar-proxy-read') {
|
||||||
list($prefix2, $name2) = \Sabre\Uri\split($prefix);
|
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.
|
// 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.
|
// 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
|
// 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) {
|
if ($user !== null) {
|
||||||
return $this->userToPrincipal($user);
|
return $this->userToPrincipal($user);
|
||||||
}
|
}
|
||||||
} elseif ($prefix === 'principals/circles') {
|
} elseif ($prefix === 'principals/circles') {
|
||||||
if ($this->userSession->getUser() !== null) {
|
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;
|
return null;
|
||||||
|
|
Loading…
Reference in New Issue