Merge pull request #6474 from owncloud/enc_detect_encrypted_files
reliable detect encrypted files
This commit is contained in:
commit
22a6bf9e5a
|
@ -464,20 +464,22 @@ class Util {
|
||||||
*/
|
*/
|
||||||
public function isEncryptedPath($path) {
|
public function isEncryptedPath($path) {
|
||||||
|
|
||||||
$relPath = Helper::getPathToRealFile($path);
|
// Disable encryption proxy so data retrieved is in its
|
||||||
|
// original form
|
||||||
|
$proxyStatus = \OC_FileProxy::$enabled;
|
||||||
|
\OC_FileProxy::$enabled = false;
|
||||||
|
|
||||||
if ($relPath === false) {
|
// we only need 24 byte from the last chunk
|
||||||
$relPath = Helper::stripUserFilesPath($path);
|
$data = '';
|
||||||
|
$handle = $this->view->fopen($path, 'r');
|
||||||
|
if (is_resource($handle) && !fseek($handle, -24, SEEK_END)) {
|
||||||
|
$data = fgets($handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
$fileKey = Keymanager::getFileKey($this->view, $this, $relPath);
|
// re-enable proxy
|
||||||
|
\OC_FileProxy::$enabled = $proxyStatus;
|
||||||
if ($fileKey === false) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
|
return Crypt::isCatfileContent($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue