aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2014-10-06 13:03:48 +0200
committerMorris Jobke <hey@morrisjobke.de>2014-10-06 13:03:48 +0200
commite5b4e54141007e50cd927e0667c81cee47873265 (patch)
treebd36df513328805a201d137f9e9582ae8fc63c47 /apps
parent6e991a53ec5bc2b70328ffbb7fd3e43811ccb426 (diff)
parent9147219377d6fec5666a03943be1892253750871 (diff)
downloadnextcloud-server-e5b4e54141007e50cd927e0667c81cee47873265.tar.gz
nextcloud-server-e5b4e54141007e50cd927e0667c81cee47873265.zip
Merge pull request #11392 from owncloud/fix_version_previews
we also encrypt/decrypt files in the versions folder
Diffstat (limited to 'apps')
-rw-r--r--apps/files_encryption/lib/proxy.php11
-rw-r--r--apps/files_encryption/tests/proxy.php38
2 files changed, 46 insertions, 3 deletions
diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php
index b406404a688..3b9dcbe7767 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 9ec1f940edd..42637a52e04 100644
--- a/apps/files_encryption/tests/proxy.php
+++ b/apps/files_encryption/tests/proxy.php
@@ -136,4 +136,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);
+ }
}