[Pkg-owncloud-commits] [owncloud] 198/258: we also encrypt/decrypt files in the versions folder for previews and if encryption is enabled/disabled

David Prévot taffit at moszumanska.debian.org
Sat Oct 11 17:22:36 UTC 2014


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

taffit pushed a commit to branch master
in repository owncloud.

commit 30398370b8c43645ec59451f7c11976adcfc5b80
Author: Bjoern Schiessle <schiessle at owncloud.com>
Date:   Thu Oct 2 12:55:46 2014 +0200

    we also encrypt/decrypt files in the versions folder for previews and if encryption is enabled/disabled
---
 apps/files_encryption/lib/proxy.php   | 11 +++++++---
 apps/files_encryption/tests/proxy.php | 38 +++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 3 deletions(-)

diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php
index b07f423..0b6cfaa 100644
--- a/apps/files_encryption/lib/proxy.php
+++ b/apps/files_encryption/lib/proxy.php
@@ -49,12 +49,17 @@ class Proxy extends \OC_FileProxy {
 	 * @param string $uid user
 	 * @return boolean
 	 */
-	private function isExcludedPath($path, $uid) {
+	protected function isExcludedPath($path, $uid) {
 
 		$view = new \OC\Files\View();
 
-		// files outside of the files-folder are excluded
-		if(strpos($path, '/' . $uid . '/files/') !== 0) {
+		$path = \OC\Files\Filesystem::normalizePath($path);
+
+		// we only encrypt/decrypt files in the files and files_versions folder
+		if(
+			strpos($path, '/' . $uid . '/files/') !== 0 &&
+			strpos($path, '/' . $uid . '/files_versions/') !== 0) {
+
 			return true;
 		}
 
diff --git a/apps/files_encryption/tests/proxy.php b/apps/files_encryption/tests/proxy.php
index 8d6bc81..a9eddd1 100644
--- a/apps/files_encryption/tests/proxy.php
+++ b/apps/files_encryption/tests/proxy.php
@@ -132,4 +132,42 @@ class Test_Encryption_Proxy extends \PHPUnit_Framework_TestCase {
 
 	}
 
+	/**
+	 * @dataProvider isExcludedPathProvider
+	 */
+	function testIsExcludedPath($path, $expected) {
+		$this->view->mkdir(dirname($path));
+		$this->view->file_put_contents($path, "test");
+
+		$testClass = new DummyProxy();
+
+		$result = $testClass->isExcludedPathTesting($path, $this->userId);
+		$this->assertSame($expected, $result);
+
+		$this->view->deleteAll(dirname($path));
+
+	}
+
+	public function isExcludedPathProvider() {
+		return array(
+			array ('/' . \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1 . '/files/test.txt', false),
+			array (\Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1 . '/files/test.txt', false),
+			array ('/files/test.txt', true),
+			array ('/' . \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1 . '/files/versions/test.txt', false),
+			array ('/' . \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1 . '/files_versions/test.txt', false),
+			array ('/' . \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1 . '/files_trashbin/test.txt', true),
+			array ('/' . \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1 . '/file/test.txt', true),
+		);
+	}
+
+}
+
+
+/**
+ * Dummy class to make protected methods available for testing
+ */
+class DummyProxy extends \OCA\Encryption\Proxy {
+	public function isExcludedPathTesting($path, $uid) {
+		return $this->isExcludedPath($path, $uid);
+	}
 }

-- 
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