Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions apps/files_sharing/lib/External/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
28 changes: 24 additions & 4 deletions apps/files_sharing/tests/External/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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 {
Expand Down
10 changes: 10 additions & 0 deletions changelog/unreleased/41599
Original file line number Diff line number Diff line change
@@ -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
Loading