#100683renameFile aborts if target file = original file, even if sanitizing the filename would result in different target filename
Description
Currently, it is not possible to sanitize a file, simply be renaming it (to the current filename) because the function ResourceStorage::renameFile returns immediately if the new file name is the same as the old filename.
code:
public function renameFile($file, $targetFileName, $conflictMode = DuplicationBehavior::RENAME)
{
// The name should be different from the current.
if ($file->getName() === $targetFileName) {
return $file;
}
$sanitizedTargetFileName = $this->driver->sanitizeFileName($targetFileName);
This leads to inconsistent behaviour.
Example:
- Rename “ö.png” to “ö.png” results in “ö.png” (not sanitized)
- but renaming “ö.png” to “ö1.png” result in “oe1.png”
The file should be renamed, if renaming it results in a different filename. This is the case if target filename = original filename, but sanitizedTargetFileName != originalfilename.
Also, if this behaviour were changed, it would be much easier to sanitize filenames. One just need to use the rename function.
## Versions
- 11.5.26
- main (12-dev)
Reviews 2
History 314
-
Gerrit Code Review pushed patch set 1 for main to change 78766 status
NewUnder Review 04/20/23, 13:35 -
Gerrit Code Review pushed patch set 2 for main to change 78766 04/20/23, 13:36
-
Gerrit Code Review pushed patch set 3 for main to change 78766 04/20/23, 13:37
-
Sybille Peters changed description 04/20/23, 13:42
-
Gerrit Code Review pushed patch set 4 for main to change 78766 04/20/23, 15:54
-
Gerrit Code Review pushed patch set 5 for main to change 78766 04/23/23, 08:43
-
Gerrit Code Review pushed patch set 6 for main to change 78766 05/03/23, 09:46
-
Gerrit Code Review pushed patch set 7 for main to change 78766 05/12/23, 17:28
-
Gerrit Code Review pushed patch set 8 for main to change 78766 05/31/23, 13:37
-
Gerrit Code Review pushed patch set 9 for main to change 78766 07/05/23, 15:44
-
Gerrit Code Review pushed patch set 10 for main to change 78766 07/05/23, 16:31
-
Gerrit Code Review pushed patch set 1 for 12.4 to change 79787 07/06/23, 07:56
-
Sybille Peters commented and changed status
Under ReviewResolved done0 %100 % 07/06/23, 08:00 -
Benni Mack changed status
ResolvedClosed 07/09/24, 12:56
Applied in changeset commit:ec81e63db80acc8bb5477a3b0eed3d8fbcca97d1.