Merge pull request #51994 from nextcloud/fix/noid/allows-some-char-from-federationid

fix(federation): allows equal signs in federation id
pull/50444/head
Ferdinand Thiessen 2025-04-23 21:23:05 +07:00 committed by GitHub
commit 56b9974c41
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

@ -106,7 +106,10 @@ class CloudIdManager implements ICloudIdManager {
$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);

@ -91,6 +91,10 @@ class CloudIdManagerTest extends TestCase {
['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'],
];
}