Skip to content

Commit

Permalink
Validation for existing mountpoint path
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterOfDeath committed Oct 25, 2018
1 parent 6ad7f32 commit 4bb6407
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/files_external/l10n/en_GB.js
Original file line number Diff line number Diff line change
Expand Up @@ -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\"",
Expand Down
1 change: 1 addition & 0 deletions apps/files_external/l10n/en_GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -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\"",
Expand Down
10 changes: 10 additions & 0 deletions apps/files_external/lib/Controller/StoragesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 4bb6407

Please sign in to comment.