From 1d944924bdb41cf18ab8cf8df7b169c0676de68c Mon Sep 17 00:00:00 2001 From: MasterOfDeath Date: Fri, 26 Oct 2018 00:37:00 +0500 Subject: [PATCH] Validation for existing mountpoint path Signed-off-by: Rinat Gumirov --- apps/files_external/l10n/en_GB.js | 1 + apps/files_external/l10n/en_GB.json | 1 + .../lib/Controller/StoragesController.php | 10 ++++++++++ 3 files changed, 12 insertions(+) diff --git a/apps/files_external/l10n/en_GB.js b/apps/files_external/l10n/en_GB.js index 735550430985e..d62cc536ec24d 100644 --- a/apps/files_external/l10n/en_GB.js +++ b/apps/files_external/l10n/en_GB.js @@ -45,6 +45,7 @@ OC.L10N.register( "Storage with ID \"%d\" not found" : "Storage with ID \"%d\" not found", "Invalid backend or authentication mechanism class" : "Invalid backend or authentication mechanism class", "Invalid mount point" : "Invalid mount point", + "Invalid path of mountpoint" : "Invalid path of mountpoint", "Objectstore forbidden" : "Objectstore forbidden", "Invalid storage backend \"%s\"" : "Invalid storage backend \"%s\"", "Not permitted to use backend \"%s\"" : "Not permitted to use backend \"%s\"", diff --git a/apps/files_external/l10n/en_GB.json b/apps/files_external/l10n/en_GB.json index 00a6b8fa27536..2a0305655ef84 100644 --- a/apps/files_external/l10n/en_GB.json +++ b/apps/files_external/l10n/en_GB.json @@ -43,6 +43,7 @@ "Storage with ID \"%d\" not found" : "Storage with ID \"%d\" not found", "Invalid backend or authentication mechanism class" : "Invalid backend or authentication mechanism class", "Invalid mount point" : "Invalid mount point", + "Invalid path of mountpoint" : "Invalid path of mountpoint", "Objectstore forbidden" : "Objectstore forbidden", "Invalid storage backend \"%s\"" : "Invalid storage backend \"%s\"", "Not permitted to use backend \"%s\"" : "Not permitted to use backend \"%s\"", diff --git a/apps/files_external/lib/Controller/StoragesController.php b/apps/files_external/lib/Controller/StoragesController.php index dd2bf69a0a635..9367e38c5d381 100644 --- a/apps/files_external/lib/Controller/StoragesController.php +++ b/apps/files_external/lib/Controller/StoragesController.php @@ -152,6 +152,16 @@ protected function validate(StorageConfig $storage) { ); } + $mountPointParentDir = dirname($mountPoint, 1); + if ($mountPointParentDir && !\OC\Files\Filesystem::is_dir($mountPointParentDir)) { + return new DataResponse( + array( + 'message' => (string)$this->l10n->t('Invalid path of mountpoint') + ), + Http::STATUS_UNPROCESSABLE_ENTITY + ); + } + if ($storage->getBackendOption('objectstore')) { // objectstore must not be sent from client side return new DataResponse(