]> source.dussan.org Git - nextcloud-server.git/commitdiff
the path need to be normalized before putting it into resolvePath()
authorThomas Müller <thomas.mueller@tmit.eu>
Thu, 10 Oct 2013 14:06:26 +0000 (16:06 +0200)
committerThomas Müller <thomas.mueller@tmit.eu>
Thu, 10 Oct 2013 14:06:26 +0000 (16:06 +0200)
otherwise the returned internalPath will not match followup calls to e.g. Cache::getID()

lib/private/files/view.php
tests/lib/files/view.php

index f74b595c8daedee2866757f4073e7fa3c76c2a0e..086e7487a6a1c38d63cdaf678824c0d5610718f2 100644 (file)
@@ -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);
        }
 
        /**
index a5107c351f4468c5a3ba95f2fbdffb37e5852254..205afba707b47045069e24aa5591a9c44b1dd742 100644 (file)
@@ -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('', '/'),
+               );
+       }
 }