folders: sanitize the path

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/888/head
Varun Patil 2023-10-19 18:51:54 -07:00
parent bbdcecc29e
commit 1a05220aa3
1 changed files with 6 additions and 1 deletions

View File

@ -19,10 +19,15 @@ class FoldersController extends GenericApiController
public function sub(string $folder): Http\Response public function sub(string $folder): Http\Response
{ {
return Util::guardEx(function () use ($folder) { return Util::guardEx(function () use ($folder) {
$folder = Util::sanitizePath($folder);
if (null === $folder) {
throw Exceptions::BadRequest('Invalid parameter folder');
}
try { try {
$node = Util::getUserFolder()->get($folder); $node = Util::getUserFolder()->get($folder);
} catch (\OCP\Files\NotFoundException) { } catch (\OCP\Files\NotFoundException) {
throw Exceptions::NotFound('Folder not found'); throw Exceptions::NotFound("Folder not found: {$folder}");
} }
if (!$node instanceof Folder) { if (!$node instanceof Folder) {