Actions
Bug #100683
closedrenameFile aborts if target file = original file, even if sanitizing the filename would result in different target filename
Status:
Closed
Priority:
Should have
Assignee:
Category:
File Abstraction Layer (FAL)
Target version:
-
Start date:
2023-04-20
Due date:
% Done:
100%
Estimated time:
TYPO3 Version:
11
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:
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)
Actions