Skip to content
Snippets Groups Projects
Commit 69b89454 authored by Björn Schießle's avatar Björn Schießle
Browse files

reliable detect encrypted files

parent 5a119452
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment