summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2021-03-25 09:15:52 +0100
committerGitHub <noreply@github.com>2021-03-25 09:15:52 +0100
commitad16b19ec7ec194d8cbd408e3b0cff76dd6d7a67 (patch)
tree435cb2beae2bf2e4017e19ec50a5b36760fdb92c /lib
parentc15172bc4ee6183aa0c68a8be71ff623a62031ff (diff)
parentaee4caed07bbb8739befd80c686e1f56943c4d12 (diff)
downloadnextcloud-server-ad16b19ec7ec194d8cbd408e3b0cff76dd6d7a67.tar.gz
nextcloud-server-ad16b19ec7ec194d8cbd408e3b0cff76dd6d7a67.zip
Merge pull request #21484 from nextcloud/better-forbidden-path-errors
show better error messages when a file with a forbidden path is encountered
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Files/Storage/Local.php12
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php
index 944b0b69959..c21364847e1 100644
--- a/lib/private/Files/Storage/Local.php
+++ b/lib/private/Files/Storage/Local.php
@@ -288,16 +288,14 @@ class Local extends \OC\Files\Storage\Common {
}
}
- private function treeContainsBlacklistedFile(string $path): bool {
+ private function checkTreeForForbiddenItems(string $path) {
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path));
foreach ($iterator as $file) {
/** @var \SplFileInfo $file */
if (Filesystem::isFileBlacklisted($file->getBasename())) {
- return true;
+ throw new ForbiddenException('Invalid path: ' . $file->getPathname(), false);
}
}
-
- return false;
}
public function rename($path1, $path2) {
@@ -337,9 +335,7 @@ class Local extends \OC\Files\Storage\Common {
return $result;
}
- if ($this->treeContainsBlacklistedFile($this->getSourcePath($path1))) {
- throw new ForbiddenException('Invalid path', false);
- }
+ $this->checkTreeForForbiddenItems($this->getSourcePath($path1));
}
return rename($this->getSourcePath($path1), $this->getSourcePath($path2));
@@ -437,7 +433,7 @@ class Local extends \OC\Files\Storage\Common {
*/
public function getSourcePath($path) {
if (Filesystem::isFileBlacklisted($path)) {
- throw new ForbiddenException('Invalid path', false);
+ throw new ForbiddenException('Invalid path: ' . $path, false);
}
$fullPath = $this->datadir . $path;