#54357Inconsistent usage of filename sanitation
Description
How would you solve this:
Before I create a file I check if the file exists in the folder where I want to create it:
\TYPO3\CMS\Core\Resource\Folder->hasFile() \TYPO3\CMS\Core\Resource\ResourceStorage->hasFileInFolder() \TYPO3\CMS\Core\Resource\Driver\AbstractDriver->fileExistsInFolder()
To add a file I use:
\TYPO3\CMS\Core\Resource\Folder->addFile() \TYPO3\CMS\Core\Resource\ResourceStorage->addFile() \TYPO3\CMS\Core\Resource\Driver\AbstractDriver->addFile()
The problem here is, that AbstractDriver->hasFile() will not call AbstractDriver->sanitizeFileName() before checking if the file exists, but add AbstractDriver->addFile() will do.
This will lead to the problem that addFile() can fail because the sanitized filename exists in the folder but not the file that was checked in the first place.
So basically I see two options:
- Make the
sanitizeFilename()method publicly available (by changing thegetDriver()in theResourceStorageclass to public and let the developers perform the sanitation manually or - Add the
sanitizeFileName()check toAbstractDriver->fileExistsInFolder()
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.