96847[BUGFIX] Do not copy a folder into its own subfolder
Commit message
Review
-
Code review CR +2 Done
- Georg Ringer +2
- Oli Bartsch +1
- Simon Schaufelberger +1
-
Verified V +2 Done
- Georg Ringer +2
- Oli Bartsch +1
- Simon Schaufelberger +1
- core-ci +1 CI
Issues 3
Files 5
- typo3/sysext/core/Classes/Resource/ResourceStorage.php2+10 −0
- typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php4+5 −0
- typo3/sysext/core/Resources/Private/Language/fileMessages.xlf+3 −0
- typo3/sysext/core/Tests/Functional/Resource/StorageRepositoryTest.php3+28 −0
- typo3/sysext/core/Tests/Functional/Utility/File/ExtendedFileUtilityTest.php+25 −0
Review log 1214
-
Wolfgang Klinger uploaded patch set 1 10/19/26, 06:37
-
core-ci voted on patch set 1 V +1 10/19/26, 06:45 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/111579
-
Simon Schaufelberger commented on patch set 1 10/19/26, 14:54
-
Wolfgang Klinger commented on patch set 1 10/19/26, 15:02
StorageRepositoryTest.php:560ReplyBecause there's an additional assert afterwards: assertDirectoryDoesNotExist. With expectException(), the test stops at the throw. Should I remove that in favor of using your suggested methods? -
Simon Schaufelberger commented on patch set 1 CR +1 V +1 10/19/26, 16:12
StorageRepositoryTest.php:560Replyah ok. didn't know that. then leave it. -
Georg Ringer voted on patch set 1 CR +1 V +1 10/21/26, 19:52
-
Oli Bartsch commented on patch set 1 CR -1 10/21/26, 20:35
I don't see this as a priority bugfix..ResourceStorage.php:2269Suggest to move the check up to right after `assureFolderCopyPermissions()`, before `BeforeFolderCopiedEvent` is dispatched. Right now listeners get a Before event for a copy that never happens. With `CANCEL` and an existing `/foo/sub/foo`, the name-conflict exception 1422723059 also wins over the more precise message.ExtendedFileUtility.php:646`func_copy` picks the message by comparing `$e->getCode()` with the literal `1792390364`, which couples it to `ResourceStorage` through a number. Please either throw a subclass of `InvalidTargetFolderException` or pre-check with `isWithinFolder()` in `func_copy`, as the filelist controllers do. Also note that the old label key `...AlreadyWithinTheFolderToBeCopied` now carries the name-conflict text, so the keys are easy to mix up.ExtendedFileUtility.php:648The message uses `$targetFolderObject->getName()`, so copying `/foo/` onto itself reads 'cannot be copied into its own subfolder "foo"', and deep targets only show the leaf name. Suggest to use the target identifier like the other messages do. -
Wolfgang Klinger uploaded patch set 2
CR +1V +110/22/26, 06:41 -
core-ci voted on patch set 2 V +1 10/22/26, 06:49 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112064
-
Oli Bartsch voted on patch set 2 CR +1 V +1 10/22/26, 20:07
-
Oli Bartsch commented on patch set 2 10/22/26, 20:07
Reply
DoneResourceStorage.php:2269ReplyDoneExtendedFileUtility.php:646ReplyDoneExtendedFileUtility.php:648ReplyDone -
Simon Schaufelberger voted on patch set 2 CR +1 V +1 10/22/26, 20:57
-
Georg Ringer voted on patch set 2 CR +2 V +2 10/23/26, 07:31
-
Georg Ringer merged patch set 3 10/23/26, 07:57
StorageRepositoryTest.php:560