From 74d30ae6c0ee9c4cec67b76fdce00763984aa352 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Thu, 26 Sep 2024 09:38:41 +0200 Subject: [PATCH 1/3] fix(files_sharing): Parse OCM share permissions from OCM and not OCS prop Signed-off-by: provokateurin --- apps/files_sharing/lib/External/Storage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files_sharing/lib/External/Storage.php b/apps/files_sharing/lib/External/Storage.php index 7b64690d53e17..c5ced250a73a5 100644 --- a/apps/files_sharing/lib/External/Storage.php +++ b/apps/files_sharing/lib/External/Storage.php @@ -389,7 +389,7 @@ public function getPermissions($path): int { $permissions = (int)$response['{http://open-collaboration-services.org/ns}share-permissions']; } elseif (isset($response['{http://open-cloud-mesh.org/ns}share-permissions'])) { // permissions provided by the OCM API - $permissions = $this->ocmPermissions2ncPermissions($response['{http://open-collaboration-services.org/ns}share-permissions'], $path); + $permissions = $this->ocmPermissions2ncPermissions($response['{http://open-cloud-mesh.org/ns}share-permissions'], $path); } elseif (isset($response['{http://owncloud.org/ns}permissions'])) { return $this->parsePermissions($response['{http://owncloud.org/ns}permissions']); } else { From f25c7b7e400ff9d6bc984b35844229fe4cc08bb5 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Thu, 26 Sep 2024 09:41:49 +0200 Subject: [PATCH 2/3] refactor(files_sharing): Make permissions prop checks less error prone Signed-off-by: provokateurin --- apps/files_sharing/lib/External/Storage.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/files_sharing/lib/External/Storage.php b/apps/files_sharing/lib/External/Storage.php index c5ced250a73a5..03e377147e9aa 100644 --- a/apps/files_sharing/lib/External/Storage.php +++ b/apps/files_sharing/lib/External/Storage.php @@ -384,14 +384,17 @@ public function isSharable($path): bool { public function getPermissions($path): int { $response = $this->propfind($path); + $ocsPermissions = $response['{http://open-collaboration-services.org/ns}share-permissions'] ?? null; + $ocmPermissions = $response['{http://open-cloud-mesh.org/ns}share-permissions'] ?? null; + $ocPermissions = $response['{http://owncloud.org/ns}permissions'] ?? null; // old federated sharing permissions - if (isset($response['{http://open-collaboration-services.org/ns}share-permissions'])) { - $permissions = (int)$response['{http://open-collaboration-services.org/ns}share-permissions']; - } elseif (isset($response['{http://open-cloud-mesh.org/ns}share-permissions'])) { + if ($ocsPermissions !== null) { + $permissions = (int)$ocsPermissions; + } elseif ($ocmPermissions !== null) { // permissions provided by the OCM API - $permissions = $this->ocmPermissions2ncPermissions($response['{http://open-cloud-mesh.org/ns}share-permissions'], $path); - } elseif (isset($response['{http://owncloud.org/ns}permissions'])) { - return $this->parsePermissions($response['{http://owncloud.org/ns}permissions']); + $permissions = $this->ocmPermissions2ncPermissions($ocmPermissions, $path); + } elseif ($ocPermissions !== null) { + return $this->parsePermissions($ocPermissions); } else { // use default permission if remote server doesn't provide the share permissions $permissions = $this->getDefaultPermissions($path); From 26cf5939ed9a8286899453b367b39d0ff0e83610 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Thu, 26 Sep 2024 14:35:25 +0200 Subject: [PATCH 3/3] fix(files_sharing): Check if propfind response is valid before accessing share permission props Signed-off-by: provokateurin --- apps/files_sharing/lib/External/Storage.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/files_sharing/lib/External/Storage.php b/apps/files_sharing/lib/External/Storage.php index 03e377147e9aa..3a52604ba8d6b 100644 --- a/apps/files_sharing/lib/External/Storage.php +++ b/apps/files_sharing/lib/External/Storage.php @@ -384,6 +384,10 @@ public function isSharable($path): bool { public function getPermissions($path): int { $response = $this->propfind($path); + if ($response === false) { + return 0; + } + $ocsPermissions = $response['{http://open-collaboration-services.org/ns}share-permissions'] ?? null; $ocmPermissions = $response['{http://open-cloud-mesh.org/ns}share-permissions'] ?? null; $ocPermissions = $response['{http://owncloud.org/ns}permissions'] ?? null;