Skip to content
Snippets Groups Projects
Commit 7b92c277 authored by Michael Gapczynski's avatar Michael Gapczynski
Browse files

Check if a file is encrypted before sharing (encrypted files cannot be shared)

parent 01b366df
No related branches found
No related tags found
No related merge requests found
...@@ -9,10 +9,11 @@ $sources = explode(';', $_POST['sources']); ...@@ -9,10 +9,11 @@ $sources = explode(';', $_POST['sources']);
$uid_shared_with = $_POST['uid_shared_with']; $uid_shared_with = $_POST['uid_shared_with'];
$permissions = $_POST['permissions']; $permissions = $_POST['permissions'];
foreach ($sources as $source) { foreach ($sources as $source) {
$file = OC_FileCache::get($source);
$path = ltrim($source, '/'); $path = ltrim($source, '/');
$source = $userDirectory.$source; $source = $userDirectory.$source;
// Check if the file exists or if the file is being reshared // Check if the file exists or if the file is being reshared
if ($source && (OC_FILESYSTEM::file_exists($path) && OC_FILESYSTEM::is_readable($path) || OC_Share::getSource($source))) { if ($source && $file['encrypted'] == false && (OC_FILESYSTEM::file_exists($path) && OC_FILESYSTEM::is_readable($path) || OC_Share::getSource($source))) {
try { try {
$shared = new OC_Share($source, $uid_shared_with, $permissions); $shared = new OC_Share($source, $uid_shared_with, $permissions);
// If this is a private link, return the token // If this is a private link, return the token
...@@ -26,8 +27,12 @@ foreach ($sources as $source) { ...@@ -26,8 +27,12 @@ foreach ($sources as $source) {
OCP\JSON::error(array('data' => array('message' => $exception->getMessage()))); OCP\JSON::error(array('data' => array('message' => $exception->getMessage())));
} }
} else { } else {
OCP\Util::writeLog('files_sharing', 'File does not exist or is not readable :'.$source, OCP\Util::ERROR); if ($file['encrypted'] == true) {
OCP\JSON::error(array('data' => array('message' => 'File does not exist or is not readable'))); OCP\JSON::error(array('data' => array('message' => 'Encrypted files cannot be shared')));
} else {
OCP\Util::writeLog('files_sharing', 'File does not exist or is not readable :'.$source, OCP\Util::ERROR);
OCP\JSON::error(array('data' => array('message' => 'File does not exist or is not readable')));
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment