Skip to content

Commit 378833e

Browse files
authored
Merge pull request #45528 from nextcloud/backport/45014/stable28
2 parents 309697d + 91c1d0b commit 378833e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/private/Files/View.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
use OCP\Files\ConnectionLostException;
6060
use OCP\Files\EmptyFileNameException;
6161
use OCP\Files\FileNameTooLongException;
62+
use OCP\Files\ForbiddenException;
6263
use OCP\Files\InvalidCharacterInPathException;
6364
use OCP\Files\InvalidDirectoryException;
6465
use OCP\Files\InvalidPathException;
@@ -731,6 +732,11 @@ public function deleteAll($directory) {
731732
public function rename($source, $target) {
732733
$absolutePath1 = Filesystem::normalizePath($this->getAbsolutePath($source));
733734
$absolutePath2 = Filesystem::normalizePath($this->getAbsolutePath($target));
735+
736+
if (str_starts_with($absolutePath2, $absolutePath1 . '/')) {
737+
throw new ForbiddenException("Moving a folder into a child folder is forbidden", false);
738+
}
739+
734740
$result = false;
735741
if (
736742
Filesystem::isValidPath($target)

0 commit comments

Comments
 (0)