diff --git a/lib/private/files/view.php b/lib/private/files/view.php index 8143b12d526310b939369de42000f554e43b099e..a56135d9b3cafe8589dcf85f86ea88dfab957018 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -110,7 +110,9 @@ class View { * @return array consisting of the storage and the internal path */ public function resolvePath($path) { - return Filesystem::resolvePath($this->getAbsolutePath($path)); + $a = $this->getAbsolutePath($path); + $p = Filesystem::normalizePath($a); + return Filesystem::resolvePath($p); } /** diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php index b2dd3963f1c301400348f3c41dfbce5668259e4e..0cc86d6651a5029a0ebaf92fda5082e32a14620a 100644 --- a/tests/lib/files/view.php +++ b/tests/lib/files/view.php @@ -434,4 +434,38 @@ class View extends \PHPUnit_Framework_TestCase { $view->file_put_contents('/asd.txt', 'foo'); $this->assertNull($this->createHookPath); } + + /** + * @dataProvider resolvePathTestProvider + */ + public function testResolvePath($expected, $pathToTest) { + $storage1 = $this->getTestStorage(); + \OC\Files\Filesystem::mount($storage1, array(), '/'); + + $view = new \OC\Files\View(''); + + $result = $view->resolvePath($pathToTest); + $this->assertEquals($expected, $result[1]); + + $exists = $view->file_exists($pathToTest); + $this->assertTrue($exists); + + $exists = $view->file_exists($result[1]); + $this->assertTrue($exists); + } + + function resolvePathTestProvider() { + return array( + array('foo.txt', 'foo.txt'), + array('foo.txt', '/foo.txt'), + array('folder', 'folder'), + array('folder', '/folder'), + array('folder', 'folder/'), + array('folder', '/folder/'), + array('folder/bar.txt', 'folder/bar.txt'), + array('folder/bar.txt', '/folder/bar.txt'), + array('', ''), + array('', '/'), + ); + } }