Skip to content
Snippets Groups Projects
Unverified Commit c275beec authored by Daniel Kesselberg's avatar Daniel Kesselberg
Browse files

Allow url without / for overwrite.cli.url

parent b7bd6bd6
No related branches found
No related tags found
No related merge requests found
...@@ -445,11 +445,10 @@ class Setup { ...@@ -445,11 +445,10 @@ class Setup {
if ($webRoot === '') { if ($webRoot === '') {
throw new InvalidArgumentException('overwrite.cli.url is empty'); throw new InvalidArgumentException('overwrite.cli.url is empty');
} }
$webRoot = parse_url($webRoot, PHP_URL_PATH); if (!filter_var($webRoot, FILTER_VALIDATE_URL)) {
if ($webRoot === null) {
throw new InvalidArgumentException('invalid value for overwrite.cli.url'); throw new InvalidArgumentException('invalid value for overwrite.cli.url');
} }
$webRoot = rtrim($webRoot, '/'); $webRoot = rtrim(parse_url($webRoot, PHP_URL_PATH), '/');
} else { } else {
$webRoot = !empty(\OC::$WEBROOT) ? \OC::$WEBROOT : '/'; $webRoot = !empty(\OC::$WEBROOT) ? \OC::$WEBROOT : '/';
} }
......
...@@ -153,14 +153,21 @@ class SetupTest extends \Test\TestCase { ...@@ -153,14 +153,21 @@ class SetupTest extends \Test\TestCase {
} }
\OC::$CLI = $cliState; \OC::$CLI = $cliState;
$this->assertEquals($webRoot, $expected); $this->assertSame($webRoot, $expected);
} }
public function findWebRootProvider(): array { public function findWebRootProvider(): array {
return [ 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/', ''],
'https://www.example.com' => ['https://www.example.com', false], 'https://www.example.com' => ['https://www.example.com', ''],
'https://nctest13pgsql.lan/nextcloud' => ['https://nctest13pgsql.lan/', ''],
'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/' => ['https://192.168.10.10/', ''],
'https://192.168.10.10' => ['https://192.168.10.10', ''],
'invalid' => ['invalid', false],
'empty' => ['', false], 'empty' => ['', false],
]; ];
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment