Skip to content

Commit be715af

Browse files
committed
Make webdav URL absolute according to spec
1 parent b962fb4 commit be715af

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

apps/federatedfilesharing/lib/Controller/OcmController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ public function processNotification($notificationType,
423423
*/
424424
protected function getProtocols() {
425425
return [
426-
'webdav' => '/public.php/webdav/'
426+
'webdav' => $this->urlGenerator->getAbsoluteURL('/public.php/webdav/')
427427
];
428428
}
429429

apps/files_sharing/lib/External/Storage.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,25 @@ protected function init() {
103103
$this->memcacheFactory,
104104
\OC::$server->getHTTPClientService()
105105
);
106+
$webDavEndpoint = $discoveryManager->getWebDavEndpoint($this->remote);
107+
// OCM endpoint is absolute, OC legacy is relative
108+
$isOcmWebDavEndpoint = \preg_match('#https?://#', $webDavEndpoint) === 1;
109+
if ($isOcmWebDavEndpoint) {
110+
// proto is anything before ://
111+
// host starts just after a proto and ends before the first slash
112+
// root starts from the first slash until the end and could be empty
113+
\preg_match_all(
114+
'#^(?<proto>https?)://(?<host>[^/]*)(?<root>.*)$#',
115+
$webDavEndpoint,
116+
$matches
117+
);
118+
$this->secure = $matches['proto'][0] === 'https';
119+
$this->host = $matches['host'][0];
120+
$this->root = isset($matches['root'][0]) ? $matches['root'][0] : '/';
121+
} else {
122+
$this->root = \rtrim($this->root, '/') . $webDavEndpoint;
123+
}
106124

107-
$this->root = \rtrim($this->root, '/') . $discoveryManager->getWebDavEndpoint($this->remote);
108125
if (!$this->root || $this->root[0] !== '/') {
109126
$this->root = '/' . $this->root;
110127
}

0 commit comments

Comments
 (0)