[Pkg-owncloud-commits] [owncloud] 74/90: detect root of mountpoint also if the trailing slash is missed

David Prévot taffit at moszumanska.debian.org
Fri Feb 6 21:10:57 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 2b83afdd7ebd9d211aa25203eaa15e978bef173c
Author: Bjoern Schiessle <schiessle at owncloud.com>
Date:   Wed Feb 4 12:07:16 2015 +0100

    detect root of mountpoint also if the trailing slash is missed
---
 lib/private/files/view.php |  5 +++++
 tests/lib/files/view.php   | 22 ++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index 7609dbe..a3f4e9e 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 ce78896..837690a 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -696,6 +696,28 @@ class View extends \PHPUnit_Framework_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'),
+		);
+	}
+
+	/**
 	 * @dataProvider tooLongPathDataProvider
 	 * @expectedException \OCP\Files\InvalidPathException
 	 */

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list