diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index 2e5c06200b48..321acfd0e1ad 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -573,20 +573,28 @@ protected function testUrl(IClientService $clientService, string $remote, bool $ public function testRemoteUrl(IClientService $clientService, string $remote) { $parsed_host = parse_url($remote, PHP_URL_HOST); $parsed_port = parse_url($remote, PHP_URL_PORT); + $parsed_path = parse_url($remote, PHP_URL_PATH); if (\is_string($parsed_host)) { $remote = $parsed_host; if ($parsed_port !== null) { $remote .= ':' . $parsed_port; } + if ($parsed_path !== null) { + $remote .= \rtrim($parsed_path, '/'); + } } else { $string_to_parse = 'http://' . $remote; $parsed_host = parse_url($string_to_parse, PHP_URL_HOST); $parsed_port = parse_url($string_to_parse, PHP_URL_PORT); + $parsed_path = parse_url($string_to_parse, PHP_URL_PATH); if (\is_string($parsed_host)) { $remote = $parsed_host; if ($parsed_port !== null) { $remote .= ':' . $parsed_port; } + if ($parsed_path !== null) { + $remote .= \rtrim($parsed_path, '/'); + } } } try { diff --git a/apps/files_sharing/tests/External/ManagerTest.php b/apps/files_sharing/tests/External/ManagerTest.php index 3e8f285aabfe..02c52e16cfe8 100644 --- a/apps/files_sharing/tests/External/ManagerTest.php +++ b/apps/files_sharing/tests/External/ManagerTest.php @@ -434,7 +434,24 @@ public function testRemoveShare(): void { $this->assertArrayHasKey('user', $called[1]); } - public function testRemoteWithValidHttps(): void { + public function providesRemoteAddress() { + return [ + [ + 'owncloud.com', + ], + [ + 'owncloud.com/cloud', + ], + [ + 'owncloud.com/cloud/', + ], + ]; + } + + /** + * @dataProvider providesRemoteAddress + */ + public function testRemoteWithValidHttps($remoteAddress): void { $client = $this->getMockBuilder(IClient::class) ->disableOriginalConstructor()->getMock(); $response = $this->getMockBuilder(IResponse::class) @@ -453,10 +470,13 @@ public function testRemoteWithValidHttps(): void { ->method('newClient') ->willReturn($client); - $this->assertEquals('https', $this->manager->testRemoteUrl($clientService, 'owncloud.com')); + $this->assertEquals('https', $this->manager->testRemoteUrl($clientService, $remoteAddress)); } - public function testRemoteWithWorkingHttp(): void { + /** + * @dataProvider providesRemoteAddress + */ + public function testRemoteWithWorkingHttp($remoteAddress): void { $client = $this->getMockBuilder(IClient::class) ->disableOriginalConstructor()->getMock(); $response = $this->getMockBuilder(IResponse::class) @@ -475,7 +495,7 @@ public function testRemoteWithWorkingHttp(): void { ->method('newClient') ->willReturn($client); - $this->assertEquals('http', $this->manager->testRemoteUrl($clientService, 'owncloud.com')); + $this->assertEquals('http', $this->manager->testRemoteUrl($clientService, $remoteAddress)); } public function testRemoteWithInvalidRemote(): void { diff --git a/changelog/unreleased/41599 b/changelog/unreleased/41599 new file mode 100644 index 000000000000..4bcbd5eb10a2 --- /dev/null +++ b/changelog/unreleased/41599 @@ -0,0 +1,10 @@ +Fix: support federation between systems in subdirectories + +If a federated server was installed in a subdirectory like: + +mydomain.com/cloud + +Then checks to see that the server is up and responding would fail. +This problem has been corrected. + +https://github.com/owncloud/core/pull/41599