mirror of
https://github.com/nextcloud/server.git
synced 2026-02-03 20:41:22 -05:00
Merge pull request #45014 from nextcloud/forbid-moving-subfolder
fix: forbid moving a folder into a subfolder of itself
This commit is contained in:
commit
d87c23242b
1 changed files with 6 additions and 0 deletions
|
|
@ -20,6 +20,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;
|
||||
|
|
@ -694,6 +695,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…
Reference in a new issue