fix(federation): allows equal signs in federation id

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
This commit is contained in:
Maxence Lange 2025-04-14 10:07:36 -01:00
parent cb92b5a64a
commit 743924ce4d
2 changed files with 8 additions and 1 deletions

View file

@ -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);

View file

@ -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'],
];
}