From ef3307f0996f1025a75a697a549166b26576e670 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Mon, 16 Sep 2013 17:42:56 +0200 Subject: [PATCH] return error if public upload is disabled --- apps/files_sharing/lib/api.php | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/apps/files_sharing/lib/api.php b/apps/files_sharing/lib/api.php index ba186094311..f641623ac10 100644 --- a/apps/files_sharing/lib/api.php +++ b/apps/files_sharing/lib/api.php @@ -77,8 +77,17 @@ class Api { case \OCP\Share::SHARE_TYPE_LINK: //allow password protection $shareWith = isset($_POST['password']) ? $_POST['password'] : null; + //check public link share + $publicUploadEnabled = \OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes'); + $encryptionEnabled = \OC_App::isEnabled('files_encryption'); + if(isset($_POST['publicUpload']) && + ($encryptionEnabled || $publicUploadEnabled !== 'yes')) { + return new \OC_OCS_Result(null, 404, "public upload disabled by the administrator"); + } $publicUpload = isset($_POST['publicUpload']) ? $_POST['publicUpload'] : 'no'; - $permission = self::getPublicLinkSharePermissions($publicUpload); + // read, create, update (7) if public upload is enabled or + // read (1) if public upload is disabled + $permission = $publicUpload === 'yes' ? 7 : 1; break; } @@ -212,24 +221,6 @@ class Api { } } - /** - * @brief get public link share permissions to allow/forbid public uploads - * @param string $publicUpload 'yes' or 'no' - * @return int permissions read (1) or create,update,read (7) - */ - private static function getPublicLinkSharePermissions($publicUpload) { - - $publicUploadEnabled = \OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes'); - - if(\OC_App::isEnabled('files_encryption') || - $publicUploadEnabled !== 'yes' || - $publicUpload === 'no') { - return 1; // read - } else { - return 7; // create, update, read - } - } - /** * @brief get file ID from a given path * @param string $path -- 2.39.5