From e82cdba53f8255a26f92c90d84b53614b0c4bb4f Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Mon, 14 Apr 2025 10:07:36 -0100 Subject: [PATCH] fix(federation): allows equal signs in federation id Signed-off-by: Maxence Lange --- lib/private/Federation/CloudIdManager.php | 5 ++++- tests/lib/Federation/CloudIdManagerTest.php | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/private/Federation/CloudIdManager.php b/lib/private/Federation/CloudIdManager.php index a7d36eda4a031..7e7adda3d3926 100644 --- a/lib/private/Federation/CloudIdManager.php +++ b/lib/private/Federation/CloudIdManager.php @@ -106,7 +106,10 @@ public function resolveCloudId(string $cloudId): ICloudId { $user = substr($id, 0, $lastValidAtPos); $remote = substr($id, $lastValidAtPos + 1); - $this->userManager->validateUserId($user); + // We accept slightly more chars when working with federationId than with a local userId. + // We remove those eventual chars from the UserId before using + // the IUserManager API to confirm its format. + $this->userManager->validateUserId(str_replace('=', '-', $user)); if (!empty($user) && !empty($remote)) { $remote = $this->ensureDefaultProtocol($remote); diff --git a/tests/lib/Federation/CloudIdManagerTest.php b/tests/lib/Federation/CloudIdManagerTest.php index 1775c18a5e912..7019cd202dbee 100644 --- a/tests/lib/Federation/CloudIdManagerTest.php +++ b/tests/lib/Federation/CloudIdManagerTest.php @@ -91,6 +91,10 @@ public function cloudIdProvider(): array { ['test@example.com/cloud/', 'test', 'example.com/cloud', 'test@example.com/cloud'], ['test@example.com/cloud/index.php', 'test', 'example.com/cloud', 'test@example.com/cloud'], ['test@example.com@example.com', 'test@example.com', 'example.com', 'test@example.com@example.com'], + + // Equal signs are not valid on Nextcloud side, but can be used by other federated OCM compatible servers + ['test==@example.com', 'test==', 'example.com', 'test==@example.com'], + ['==@example.com', '==', 'example.com', '==@example.com'], ]; }