From: Thomas Müller Date: Thu, 10 Oct 2013 14:06:26 +0000 (+0200) Subject: the path need to be normalized before putting it into resolvePath() X-Git-Tag: v6.0.0alpha2~38^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=bc6e352ccd41f0641144fc1fc2d4e52e8f5532c0;p=nextcloud-server.git the path need to be normalized before putting it into resolvePath() otherwise the returned internalPath will not match followup calls to e.g. Cache::getID() --- diff --git a/lib/private/files/view.php b/lib/private/files/view.php index f74b595c8da..086e7487a6a 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 a5107c351f4..205afba707b 100644 --- a/tests/lib/files/view.php +++ b/tests/lib/files/view.php @@ -416,4 +416,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('', '/'), + ); + } }