mirror of
https://github.com/nextcloud/server.git
synced 2026-04-21 14:23:17 -04:00
reuse isValidPath from Filesystem
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
baf8d2e1d0
commit
5ac0e9b63b
2 changed files with 3 additions and 15 deletions
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue