Skip to content

Commit 56b9974

Browse files
authored
Merge pull request #51994 from nextcloud/fix/noid/allows-some-char-from-federationid
fix(federation): allows equal signs in federation id
2 parents 366eb9c + 743924c commit 56b9974

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
@@ -106,7 +106,10 @@ public function resolveCloudId(string $cloudId): ICloudId {
106106
$user = substr($id, 0, $lastValidAtPos);
107107
$remote = substr($id, $lastValidAtPos + 1);
108108

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

111114
if (!empty($user) && !empty($remote)) {
112115
$remote = $this->ensureDefaultProtocol($remote);

tests/lib/Federation/CloudIdManagerTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ public function cloudIdProvider(): array {
9191
['[email protected]/cloud/', 'test', 'example.com/cloud', '[email protected]/cloud'],
9292
['[email protected]/cloud/index.php', 'test', 'example.com/cloud', '[email protected]/cloud'],
9393
['[email protected]@example.com', '[email protected]', 'example.com', '[email protected]@example.com'],
94+
95+
// Equal signs are not valid on Nextcloud side, but can be used by other federated OCM compatible servers
96+
['[email protected]', 'test==', 'example.com', '[email protected]'],
97+
['[email protected]', '==', 'example.com', '[email protected]'],
9498
];
9599
}
96100

0 commit comments

Comments
 (0)