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
5 changes: 2 additions & 3 deletions lib/private/Setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -445,11 +445,10 @@ private static function findWebRoot(SystemConfig $config): string {
if ($webRoot === '') {
throw new InvalidArgumentException('overwrite.cli.url is empty');
}
$webRoot = parse_url($webRoot, PHP_URL_PATH);
if ($webRoot === null) {
if (!filter_var($webRoot, FILTER_VALIDATE_URL)) {
throw new InvalidArgumentException('invalid value for overwrite.cli.url');
}
$webRoot = rtrim($webRoot, '/');
$webRoot = rtrim(parse_url($webRoot, PHP_URL_PATH), '/');
} else {
$webRoot = !empty(\OC::$WEBROOT) ? \OC::$WEBROOT : '/';
}
Expand Down
14 changes: 12 additions & 2 deletions tests/lib/SetupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,24 @@ public function testFindWebRootCli($url, $expected) {
}

\OC::$CLI = $cliState;
$this->assertEquals($webRoot, $expected);
$this->assertSame($webRoot, $expected);
}

public function findWebRootProvider(): array {
return [
'https://www.example.com/nextcloud/' => ['https://www.example.com/nextcloud/', '/nextcloud'],
'https://www.example.com/nextcloud' => ['https://www.example.com/nextcloud', '/nextcloud'],
'https://www.example.com/' => ['https://www.example.com/', ''],
'https://www.example.com' => ['https://www.example.com', false],
'https://www.example.com' => ['https://www.example.com', ''],
'https://nctest13pgsql.lan/test123/' => ['https://nctest13pgsql.lan/test123/', '/test123'],
'https://nctest13pgsql.lan/test123' => ['https://nctest13pgsql.lan/test123', '/test123'],
'https://nctest13pgsql.lan/' => ['https://nctest13pgsql.lan/', ''],
'https://nctest13pgsql.lan' => ['https://nctest13pgsql.lan', ''],
'https://192.168.10.10/nc/' => ['https://192.168.10.10/nc/', '/nc'],
'https://192.168.10.10/nc' => ['https://192.168.10.10/nc', '/nc'],
'https://192.168.10.10/' => ['https://192.168.10.10/', ''],
'https://192.168.10.10' => ['https://192.168.10.10', ''],
'invalid' => ['invalid', false],
'empty' => ['', false],
];
}
Expand Down