reuse isValidPath from Filesystem

Signed-off-by: Robin Appelman <robin@icewind.nl>
pull/38150/head
Robin Appelman 2 years ago
parent baf8d2e1d0
commit 5ac0e9b63b
No known key found for this signature in database
GPG Key ID: 42B69D8A64526EFB
  1. 10
      lib/private/Files/Node/LazyFolder.php
  2. 8
      lib/private/Files/Node/Node.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
*/

@ -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…
Cancel
Save