Open solracsf opened 1 year ago
Same problem here:
I found this in the logs on the receiving side (redacted):
{"reqId":"FU7dy6b8GPI0HNO5jQbg","level":0,"time":"2023-06-06T11:36:16+00:00","remoteAddr":"14X.X.X.X","user":"--","app":"cloud_federation_api","method":"POST","url":"/ocm/shares","message":"shareWith before, user@domain.tld","userAgent":"Nextcloud Server Crawler","version":"26.0.1.1","data":{"app":"cloud_federation_api"}}
{"reqId":"FU7dy6b8GPI0HNO5jQbg","level":0,"time":"2023-06-06T11:36:16+00:00","remoteAddr":"14X.X.X.X","user":"--","app":"cloud_federation_api","method":"POST","url":"/ocm/shares","message":"shareWith after, user@domain.tld","userAgent":"Nextcloud Server Crawler","version":"26.0.1.1","data":{"app":"cloud_federation_api"}}
I noticed that NC was not on latest stable, so I updated to 26.0.2 afterwards without any impact on the problem.
The problem is most probably here
/**
* @param string $cloudId
* @return ICloudId
* @throws \InvalidArgumentException
*/
public function resolveCloudId(string $cloudId): ICloudId {
// TODO magic here to get the url and user instead of just splitting on @
if (!$this->isValidCloudId($cloudId)) {
throw new \InvalidArgumentException('Invalid cloud id');
}
// Find the first character that is not allowed in user names
$id = $this->fixRemoteURL($cloudId);
$posSlash = strpos($id, '/');
$posColon = strpos($id, ':');
if ($posSlash === false && $posColon === false) {
$invalidPos = \strlen($id);
} elseif ($posSlash === false) {
$invalidPos = $posColon;
} elseif ($posColon === false) {
$invalidPos = $posSlash;
} else {
$invalidPos = min($posSlash, $posColon);
}
$lastValidAtPos = strrpos($id, '@', $invalidPos - strlen($id));
if ($lastValidAtPos !== false) {
$user = substr($id, 0, $lastValidAtPos);
$remote = substr($id, $lastValidAtPos + 1);
$this->userManager->validateUserId($user);
if (!empty($user) && !empty($remote)) {
return new CloudId($id, $user, $remote, $this->getDisplayNameFromContact($id));
}
}
throw new \InvalidArgumentException('Invalid cloud id');
}
I was able to test it. It seems to work using NC 26.0.5. on both ends.
I will try if this is update safe after updating one instance to 27.0.2
⚠️ This issue respects the following points: ⚠️
Bug description
Federated shares for user in format email+domain fails.
Steps to reproduce
user@email.com@cloud.nc.com
Expected behavior
Format
user@email.com@cloud.nc.com
is accepted.Installation method
Community Manual installation with Archive
Nextcloud Server version
26
Operating system
Debian/Ubuntu
PHP engine version
PHP 8.1
Web server
Apache (supported)
Database engine version
MariaDB
Is this bug present after an update or on a fresh install?
Fresh Nextcloud Server install
Are you using the Nextcloud Server Encryption module?
Encryption is Disabled
What user-backends are you using?
Configuration report
List of activated Apps
Nextcloud Signing status
Nextcloud Logs
No response
Additional info
No response