diff options
-rw-r--r-- | lib/private/files/view.php | 5 | ||||
-rw-r--r-- | tests/lib/files/view.php | 22 |
2 files changed, 27 insertions, 0 deletions
diff --git a/lib/private/files/view.php b/lib/private/files/view.php index 6c720a6f5c0..3bc9fdff1ee 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -87,6 +87,11 @@ class View { if ($this->fakeRoot == '') { return $path; } + + if (rtrim($path,'/') === rtrim($this->fakeRoot, '/')) { + return '/'; + } + if (strpos($path, $this->fakeRoot) !== 0) { return null; } else { diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php index 9ddc9c80475..f6af59d52be 100644 --- a/tests/lib/files/view.php +++ b/tests/lib/files/view.php @@ -729,6 +729,28 @@ class View extends \Test\TestCase { ); } + /** + * @dataProvider relativePathProvider + */ + function testGetRelativePath($absolutePath, $expectedPath) { + $view = new \OC\Files\View('/files'); + // simulate a external storage mount point which has a trailing slash + $view->chroot('/files/'); + $this->assertEquals($expectedPath, $view->getRelativePath($absolutePath)); + } + + function relativePathProvider() { + return array( + array('/files/', '/'), + array('/files', '/'), + array('/files/0', '0'), + array('/files/false', 'false'), + array('/files/true', 'true'), + array('/files/test', 'test'), + array('/files/test/foo', 'test/foo'), + ); + } + public function testFileView() { $storage = new Temporary(array()); $scanner = $storage->getScanner(); |