summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2018-11-20 13:28:07 +0100
committerJoas Schilling <coding@schilljs.com>2018-11-20 13:36:16 +0100
commitb8fcf6e9b3d492d19bbbdcd144428fef9bbf2324 (patch)
tree49884da795153faa34261806508cd2775d15788b
parent2b18b9ae96d973e601fda2074e6153b0f5562eab (diff)
downloadnextcloud-server-b8fcf6e9b3d492d19bbbdcd144428fef9bbf2324.tar.gz
nextcloud-server-b8fcf6e9b3d492d19bbbdcd144428fef9bbf2324.zip
Allow empty strings in getAbsoluteURL
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--lib/private/URLGenerator.php4
-rw-r--r--tests/lib/UrlGeneratorTest.php2
2 files changed, 4 insertions, 2 deletions
diff --git a/lib/private/URLGenerator.php b/lib/private/URLGenerator.php
index f4a83138e4c..167690f3a6e 100644
--- a/lib/private/URLGenerator.php
+++ b/lib/private/URLGenerator.php
@@ -237,13 +237,13 @@ class URLGenerator implements IURLGenerator {
* @return string the absolute version of the url
*/
public function getAbsoluteURL(string $url): string {
- $separator = $url[0] === '/' ? '' : '/';
+ $separator = strpos($url, '/') === 0 ? '' : '/';
if (\OC::$CLI && !\defined('PHPUNIT_RUN')) {
return rtrim($this->config->getSystemValue('overwrite.cli.url'), '/') . '/' . ltrim($url, '/');
}
// The ownCloud web root can already be prepended.
- if(substr($url, 0, \strlen(\OC::$WEBROOT)) === \OC::$WEBROOT) {
+ if(\OC::$WEBROOT !== '' && strpos($url, \OC::$WEBROOT) === 0) {
$url = substr($url, \strlen(\OC::$WEBROOT));
}
diff --git a/tests/lib/UrlGeneratorTest.php b/tests/lib/UrlGeneratorTest.php
index cc93febd53d..9a8e588a229 100644
--- a/tests/lib/UrlGeneratorTest.php
+++ b/tests/lib/UrlGeneratorTest.php
@@ -145,6 +145,8 @@ class UrlGeneratorTest extends \Test\TestCase {
public function provideSubDirURLs() {
return [
+ ['', 'http://localhost/nextcloud/'],
+ ['/', 'http://localhost/nextcloud/'],
['index.php', 'http://localhost/nextcloud/index.php'],
['/index.php', 'http://localhost/nextcloud/index.php'],
['/apps/index.php', 'http://localhost/nextcloud/apps/index.php'],