Merge pull request #52384 from nextcloud/backport/51994/stable28

[stable28] fix(federation): allows equal signs in federation id
This commit is contained in:
Joas Schilling 2025-06-04 08:34:10 +02:00 committed by GitHub
commit 151fa6995f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View file

@ -126,7 +126,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)) {
return new CloudId($id, $user, $remote, $this->getDisplayNameFromContact($id));

View file

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