summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-04-17 12:38:58 +0200
committerRobin Appelman <icewind@owncloud.com>2014-04-17 12:38:58 +0200
commit2264615d207c38f6daa6a72b7285e99cbf551038 (patch)
tree872d2473a1da043c0c5bd73af3a2ab8327d10c5f
parentec594eb53084c62936d47d22757cdbc0fd0dcd5a (diff)
downloadnextcloud-server-2264615d207c38f6daa6a72b7285e99cbf551038.tar.gz
nextcloud-server-2264615d207c38f6daa6a72b7285e99cbf551038.zip
Verify that a file exists before we share it
-rw-r--r--lib/public/share.php11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/public/share.php b/lib/public/share.php
index 359a3288718..75f8512560e 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -391,6 +391,17 @@ class Share {
public static function shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions) {
$uidOwner = \OC_User::getUser();
$sharingPolicy = \OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global');
+
+ // verify that the file exists before we try to share it
+ if ($itemType === 'file' or $itemType === 'folder') {
+ $path = \OC\Files\Filesystem::getPath($itemSource);
+ if (!$path) {
+ $message = 'Sharing failed, because the file does not exist';
+ \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
+ throw new \Exception($message);
+ }
+ }
+
// Verify share type and sharing conditions are met
if ($shareType === self::SHARE_TYPE_USER) {
if ($shareWith == $uidOwner) {