Skip to content

Commit 151fa69

Browse files
Merge pull request #52384 from nextcloud/backport/51994/stable28
[stable28] fix(federation): allows equal signs in federation id
2 parents 2f63dac + a8280bc commit 151fa69

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/private/Federation/CloudIdManager.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ public function resolveCloudId(string $cloudId): ICloudId {
126126
$user = substr($id, 0, $lastValidAtPos);
127127
$remote = substr($id, $lastValidAtPos + 1);
128128

129-
$this->userManager->validateUserId($user);
129+
// We accept slightly more chars when working with federationId than with a local userId.
130+
// We remove those eventual chars from the UserId before using
131+
// the IUserManager API to confirm its format.
132+
$this->userManager->validateUserId(str_replace('=', '-', $user));
130133

131134
if (!empty($user) && !empty($remote)) {
132135
return new CloudId($id, $user, $remote, $this->getDisplayNameFromContact($id));

tests/lib/Federation/CloudIdManagerTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ public function cloudIdProvider() {
7070
['test@example.com/cloud/', 'test', 'example.com/cloud', 'test@example.com/cloud'],
7171
['test@example.com/cloud/index.php', 'test', 'example.com/cloud', 'test@example.com/cloud'],
7272
['test@example.com@example.com', 'test@example.com', 'example.com', 'test@example.com@example.com'],
73+
74+
// Equal signs are not valid on Nextcloud side, but can be used by other federated OCM compatible servers
75+
['test==@example.com', 'test==', 'example.com', 'test==@example.com'],
76+
['==@example.com', '==', 'example.com', '==@example.com'],
7377
];
7478
}
7579

0 commit comments

Comments
 (0)