Repository navigation
fix: block local remote shares on typos and contacts with a local Cloud ID - #64318
salmart-dev wants to merge 3 commits into
Conversation
Stops considering emails/cloudID with casing differences in the user or domain part as different, to avoid a typo from resulting into a remote share. Signed-off-by: Salvatore Martire <4652631+salmart-dev@users.noreply.github.com>
This prevents users accidentally sharing via remote shares to local users just because they saved them as contacts. Signed-off-by: Salvatore Martire <4652631+salmart-dev@users.noreply.github.com>
Signed-off-by: Salvatore Martire <4652631+salmart-dev@users.noreply.github.com>
| return mb_strtolower($remoteCloudId->getUser()) === mb_strtolower($localCloudId->getUser()) | ||
| && $this->normalizeRemote($remoteCloudId->getRemote()) === $this->normalizeRemote($localCloudId->getRemote()); | ||
| } | ||
|
|
||
| /** | ||
| * Normalize a remote for comparison: the protocol and trailing slashes are | ||
| * dropped, and the host is lowercased. The path is kept as-is, as it is | ||
| * case-sensitive (RFC 3986, section 6.2.2.1). | ||
| */ | ||
| private function normalizeRemote(string $remote): string { | ||
| $remote = rtrim(preg_replace('#^https?://#i', '', $remote), '/'); | ||
| $pathPosition = strpos($remote, '/'); | ||
| if ($pathPosition === false) { | ||
| return strtolower($remote); | ||
| } | ||
|
|
||
| return strtolower(substr($remote, 0, $pathPosition)) . substr($remote, $pathPosition); | ||
| } |
There was a problem hiding this comment.
This logic should be moved into a new method in ICloudId, so it's reusable.
|
account for |
| return false; | ||
| } | ||
|
|
||
| return mb_strtolower($remoteCloudId->getUser()) === mb_strtolower($localCloudId->getUser()) |
There was a problem hiding this comment.
A fix in this regard should respect the way that the user backend would actually do comparison for the user ID. According to the OCM specs, the identifier is case-sensitive, so lower-casing for comparison is only okay when the backend would do the same to identify the user. So lower-casing may be okay for checking if an inputted cloud ID may match a local user, but is not okay to compare if two remote users are the same user, as the decision about casing can only be done by the remote.
Summary
This PR addresses two problems leading to confusing remote shares to local users, when the server is configured with
allow_local_remote_serversset toyes.TODO
Checklist
3. to review, feature component)stable32)AI (if applicable)