fix: forbid moving a folder into a subfolder of itself

Signed-off-by: Robin Appelman <robin@icewind.nl>
forbid-moving-subfolder
Robin Appelman 1 week ago
parent c0b54c7577
commit 5398b19b31
No known key found for this signature in database
GPG Key ID: 42B69D8A64526EFB

@ -59,6 +59,7 @@ use OCP\Files\Cache\ICacheEntry;
use OCP\Files\ConnectionLostException;
use OCP\Files\EmptyFileNameException;
use OCP\Files\FileNameTooLongException;
use OCP\Files\ForbiddenException;
use OCP\Files\InvalidCharacterInPathException;
use OCP\Files\InvalidDirectoryException;
use OCP\Files\InvalidPathException;
@ -733,6 +734,11 @@ class View {
public function rename($source, $target) {
$absolutePath1 = Filesystem::normalizePath($this->getAbsolutePath($source));
$absolutePath2 = Filesystem::normalizePath($this->getAbsolutePath($target));
if (str_starts_with($absolutePath2, $absolutePath1 . '/')) {
throw new ForbiddenException("Moving a folder into a child folder is forbidden", false);
}
$targetParts = explode('/', $absolutePath2);
$targetUser = $targetParts[1] ?? null;
$result = false;

Loading…
Cancel
Save