From: Michael Gapczynski Date: Tue, 15 May 2012 15:29:02 +0000 (-0400) Subject: Check if a file is encrypted before sharing (encrypted files cannot be shared) X-Git-Tag: v4.0.0RC2~46 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7b92c2777702bddb4595edc93aaac0b1db5e67f9;p=nextcloud-server.git Check if a file is encrypted before sharing (encrypted files cannot be shared) --- diff --git a/apps/files_sharing/ajax/share.php b/apps/files_sharing/ajax/share.php index 4478144e92f..ec3c25998af 100644 --- a/apps/files_sharing/ajax/share.php +++ b/apps/files_sharing/ajax/share.php @@ -9,10 +9,11 @@ $sources = explode(';', $_POST['sources']); $uid_shared_with = $_POST['uid_shared_with']; $permissions = $_POST['permissions']; foreach ($sources as $source) { + $file = OC_FileCache::get($source); $path = ltrim($source, '/'); $source = $userDirectory.$source; // 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 { $shared = new OC_Share($source, $uid_shared_with, $permissions); // If this is a private link, return the token @@ -26,8 +27,12 @@ foreach ($sources as $source) { OCP\JSON::error(array('data' => array('message' => $exception->getMessage()))); } } 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'))); + if ($file['encrypted'] == true) { + 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'))); + } } }