reuse isValidPath from Filesystem

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2023-09-01 15:58:28 +02:00
parent baf8d2e1d0
commit 5ac0e9b63b
No known key found for this signature in database
GPG key ID: 42B69D8A64526EFB
2 changed files with 3 additions and 15 deletions

View file

@ -26,6 +26,7 @@ declare(strict_types=1);
namespace OC\Files\Node;
use OC\Files\Filesystem;
use OC\Files\Utils\PathHelper;
use OCP\Files\Folder;
use OCP\Constants;
@ -418,7 +419,7 @@ class LazyFolder implements Folder {
public function getFullPath($path) {
if (isset($this->data['path'])) {
$path = PathHelper::normalizePath($path);
if (!$this->isValidPath($path)) {
if (!Filesystem::isValidPath($path)) {
throw new NotPermittedException('Invalid path "' . $path . '"');
}
return $this->data['path'] . $path;
@ -426,13 +427,6 @@ class LazyFolder implements Folder {
return $this->__call(__FUNCTION__, func_get_args());
}
public function isValidPath($path) {
if (!str_starts_with($path, '/')) {
$path = '/' . $path;
}
return !(str_contains($path, '/../') || strrchr($path, '/') === '/..');
}
/**
* @inheritDoc
*/

View file

@ -334,13 +334,7 @@ class Node implements INode {
* @return bool
*/
public function isValidPath($path) {
if (!$path || $path[0] !== '/') {
$path = '/' . $path;
}
if (strstr($path, '/../') || strrchr($path, '/') === '/..') {
return false;
}
return true;
return Filesystem::isValidPath($path);
}
public function isMounted() {