diff options
author | Björn Schießle <schiessle@owncloud.com> | 2013-12-17 09:12:02 -0800 |
---|---|---|
committer | Björn Schießle <schiessle@owncloud.com> | 2013-12-17 09:12:02 -0800 |
commit | 22a6bf9e5a20a6fb3c7c24e4e1e5275c9d7346ad (patch) | |
tree | 8f38f723ec92237567b3cfe3eba15e1ebef6c214 /apps/files_encryption | |
parent | 0b9f4130b0fff4aaa378f7497c956717dcd19336 (diff) | |
parent | 69b89454a4070c0ae3e7e8b6e37f310a2ee28e73 (diff) | |
download | nextcloud-server-22a6bf9e5a20a6fb3c7c24e4e1e5275c9d7346ad.tar.gz nextcloud-server-22a6bf9e5a20a6fb3c7c24e4e1e5275c9d7346ad.zip |
Merge pull request #6474 from owncloud/enc_detect_encrypted_files
reliable detect encrypted files
Diffstat (limited to 'apps/files_encryption')
-rw-r--r-- | apps/files_encryption/lib/util.php | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php index bf7c49504a2..d4aa4d31649 100644 --- a/apps/files_encryption/lib/util.php +++ b/apps/files_encryption/lib/util.php @@ -464,20 +464,22 @@ class Util { */ public function isEncryptedPath($path) { - $relPath = Helper::getPathToRealFile($path); - - if ($relPath === false) { - $relPath = Helper::stripUserFilesPath($path); - } - - $fileKey = Keymanager::getFileKey($this->view, $this, $relPath); + // Disable encryption proxy so data retrieved is in its + // original form + $proxyStatus = \OC_FileProxy::$enabled; + \OC_FileProxy::$enabled = false; - if ($fileKey === false) { - return false; + // we only need 24 byte from the last chunk + $data = ''; + $handle = $this->view->fopen($path, 'r'); + if (is_resource($handle) && !fseek($handle, -24, SEEK_END)) { + $data = fgets($handle); } - return true; + // re-enable proxy + \OC_FileProxy::$enabled = $proxyStatus; + return Crypt::isCatfileContent($data); } /** |