folders: sanitize the path
Signed-off-by: Varun Patil <radialapps@gmail.com>pull/888/head
parent
bbdcecc29e
commit
1a05220aa3
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue