]> source.dussan.org Git - nextcloud-server.git/commitdiff
ensure the view's root is a subfolder of the the default root, not only starting...
authorRobin Appelman <icewind@owncloud.com>
Wed, 9 Oct 2013 18:46:43 +0000 (20:46 +0200)
committerRobin Appelman <icewind@owncloud.com>
Wed, 9 Oct 2013 18:46:43 +0000 (20:46 +0200)
lib/private/files/view.php
tests/lib/files/view.php

index aa08a5f7cc9f2ad48ec756068283281850ff6d22..76c73ea23d7ad7da3d1069ba72414573d8c46e1e 100644 (file)
@@ -709,7 +709,10 @@ class View {
                        return false;
                }
                $defaultRoot = Filesystem::getRoot();
-               return (strlen($this->fakeRoot) >= strlen($defaultRoot)) && (substr($this->fakeRoot, 0, strlen($defaultRoot)) === $defaultRoot);
+               if($this->fakeRoot === $defaultRoot){
+                       return true;
+               }
+               return (strlen($this->fakeRoot) > strlen($defaultRoot)) && (substr($this->fakeRoot, 0, strlen($defaultRoot) + 1) === $defaultRoot . '/');
        }
 
        private function runHooks($hooks, $path, $post = false) {
index 3043f132b73ea118af1e7bcd1f6e4f752c613f70..e2107a03614a3f280a4f9a892c5bcfa449ac5f43 100644 (file)
@@ -391,4 +391,22 @@ class View extends \PHPUnit_Framework_TestCase {
                $this->storages[] = $storage;
                return $storage;
        }
+
+       /**
+        * @medium
+        */
+       function testViewHooksIfRootStartsTheSame() {
+               $storage1 = $this->getTestStorage();
+               $storage2 = $this->getTestStorage();
+               $defaultRoot = \OC\Files\Filesystem::getRoot();
+               \OC\Files\Filesystem::mount($storage1, array(), '/');
+               \OC\Files\Filesystem::mount($storage2, array(), $defaultRoot . '_substorage');
+               \OC_Hook::connect('OC_Filesystem', 'post_write', $this, 'dummyHook');
+
+               $subView = new \OC\Files\View($defaultRoot . '_substorage');
+               $this->hookPath = null;
+
+               $subView->file_put_contents('/foo.txt', 'asd');
+               $this->assertNull($this->hookPath);
+       }
 }