aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2024-03-25 13:20:16 +0100
committerJoas Schilling <coding@schilljs.com>2024-03-25 14:21:52 +0100
commitdababa5138a4c6c313bb731f20356a2fb169f7e1 (patch)
tree4d1b307a685b9e277ab2ccf69f5b1ee15d078a87 /lib
parent46906b7d69642f7e5b1dc031e00921b39b27dce8 (diff)
downloadnextcloud-server-dababa5138a4c6c313bb731f20356a2fb169f7e1.tar.gz
nextcloud-server-dababa5138a4c6c313bb731f20356a2fb169f7e1.zip
fix(federation): Fix creating local cloudIds with http:// protocol
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Federation/CloudIdManager.php25
1 files changed, 12 insertions, 13 deletions
diff --git a/lib/private/Federation/CloudIdManager.php b/lib/private/Federation/CloudIdManager.php
index 22b06af386f..70431ce2289 100644
--- a/lib/private/Federation/CloudIdManager.php
+++ b/lib/private/Federation/CloudIdManager.php
@@ -168,17 +168,16 @@ class CloudIdManager implements ICloudIdManager {
public function getCloudId(string $user, ?string $remote): ICloudId {
$isLocal = $remote === null;
if ($isLocal) {
- $remote = rtrim($this->removeProtocolFromUrl($this->urlGenerator->getAbsoluteURL('/')), '/');
- $fixedRemote = $this->fixRemoteURL($remote);
- $host = $fixedRemote;
- } else {
- // note that for remote id's we don't strip the protocol for the remote we use to construct the CloudId
- // this way if a user has an explicit non-https cloud id this will be preserved
- // we do still use the version without protocol for looking up the display name
- $fixedRemote = $this->fixRemoteURL($remote);
- $host = $this->removeProtocolFromUrl($fixedRemote);
+ $remote = rtrim($this->urlGenerator->getAbsoluteURL('/'), '/');
}
+ // note that for remote id's we don't strip the protocol for the remote we use to construct the CloudId
+ // this way if a user has an explicit non-https cloud id this will be preserved
+ // we do still use the version without protocol for looking up the display name
+ $remote = $this->removeProtocolFromUrl($remote, true);
+ $remote = $this->fixRemoteURL($remote);
+ $host = $this->removeProtocolFromUrl($remote);
+
$key = $user . '@' . ($isLocal ? 'local' : $host);
$cached = $this->cache[$key] ?? $this->memCache->get($key);
if ($cached) {
@@ -197,23 +196,23 @@ class CloudIdManager implements ICloudIdManager {
$data = [
'id' => $id,
'user' => $user,
- 'remote' => $fixedRemote,
+ 'remote' => $remote,
'displayName' => $displayName,
];
$this->cache[$key] = $data;
$this->memCache->set($key, $data, 15 * 60);
- return new CloudId($id, $user, $fixedRemote, $displayName);
+ return new CloudId($id, $user, $remote, $displayName);
}
/**
* @param string $url
* @return string
*/
- public function removeProtocolFromUrl(string $url): string {
+ public function removeProtocolFromUrl(string $url, bool $httpsOnly = false): string {
if (str_starts_with($url, 'https://')) {
return substr($url, 8);
}
- if (str_starts_with($url, 'http://')) {
+ if (!$httpsOnly && str_starts_with($url, 'http://')) {
return substr($url, 7);
}