Merge pull request #11446 from nextcloud/bugfix/10678/pretty-urls-dont-work

Allow overwrite.cli.url without trailing slash
This commit is contained in:
Morris Jobke 2018-10-02 23:39:30 +02:00 committed by GitHub
commit 8ede3f6346
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 5 deletions

View file

@ -451,11 +451,10 @@ class Setup {
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 : '/';
}

View file

@ -153,14 +153,24 @@ class SetupTest extends \Test\TestCase {
}
\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],
];
}