diff options
author | Robin Appelman <robin@icewind.nl> | 2023-09-01 15:58:28 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2023-09-04 18:42:50 +0200 |
commit | 5ac0e9b63b173a1a06c09cbfdce985dcabef1e2b (patch) | |
tree | 78447fad9b6d1c3378fcd7fb0ac478ac07900194 | |
parent | baf8d2e1d01201b32e74f2a46fd217f40bbcf473 (diff) | |
download | nextcloud-server-5ac0e9b63b173a1a06c09cbfdce985dcabef1e2b.tar.gz nextcloud-server-5ac0e9b63b173a1a06c09cbfdce985dcabef1e2b.zip |
reuse isValidPath from Filesystem
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r-- | lib/private/Files/Node/LazyFolder.php | 10 | ||||
-rw-r--r-- | lib/private/Files/Node/Node.php | 8 |
2 files changed, 3 insertions, 15 deletions
diff --git a/lib/private/Files/Node/LazyFolder.php b/lib/private/Files/Node/LazyFolder.php index 2400d8e8097..f13cdc0c4f9 100644 --- a/lib/private/Files/Node/LazyFolder.php +++ b/lib/private/Files/Node/LazyFolder.php @@ -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 */ diff --git a/lib/private/Files/Node/Node.php b/lib/private/Files/Node/Node.php index 4f466dde532..4b916bd9c1b 100644 --- a/lib/private/Files/Node/Node.php +++ b/lib/private/Files/Node/Node.php @@ -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() { |