Bug #65673
closed"0" is not accepted as a valid file name
100%
Description
After sanitizing a filename in LocalDriver, the result $cleanFilename is checked for ... any surviving characters, I guess?
Line 320-325, typo3/sysext/core/Classes/Resource/Driver/LocalDriver.php: if (!$cleanFileName) { throw new \TYPO3\CMS\Core\Resource\Exception\InvalidFileNameException( 'File name ' . $cleanFileName . ' is invalid.', 1320288991 ); }
The purpose of the error message is not quite clear; either $cleanFileName is empty since the file name did not contain any valid characters to begin with, or it is NULL as a return value of preg_replace when the function encountered an error.
The check, however, catches any file name that evaluates to false after coercion (although the file name is perfectly valid).
Without any deeper understanding, I propose to change the condition to
if (is_null($cleanFileName) || empty($cleanFileName)) {
Discuss!
Updated by Malte Muth over 9 years ago
Actually, after reading up how empty works, the second condition should be
0 == strlen($cleanFileName)
Updated by Markus Klein over 9 years ago
- Category set to File Abstraction Layer (FAL)
- Status changed from New to Accepted
- Target version set to next-patchlevel
you shouldn't use strlen() to check for empty strings, a straight comparision === '' is much faster. ;-)
Wanna push a patch for that?
Updated by Gerrit Code Review over 9 years ago
- Status changed from Accepted to Under Review
Patch set 1 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/37768
Updated by Malte Muth over 9 years ago
Hi Markus,
thanks for the hint. I'm new to the gerrit process, can you let me know if what I've done is correct?
Also: I think the error message should be changed to include the unsanitized filename in some way. Right now, $cleanFileName is not display-able anyway.
Updated by Gerrit Code Review over 9 years ago
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/37782
Updated by Gerrit Code Review over 9 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/37782
Updated by Gerrit Code Review over 9 years ago
Patch set 2 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/37768
Updated by Malte Muth over 9 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 817be1d35c625d751ed28619e76ec8a04d32164a.
Updated by Gerrit Code Review over 9 years ago
- Status changed from Resolved to Under Review
Patch set 3 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/37768
Updated by Malte Muth over 9 years ago
- Status changed from Under Review to Resolved
Applied in changeset eb4a357219083252efae3d7fa4d0b3ac0f9a1cac.