Bug #55721
closedwrong filenames when UTF8filesystem is set and 'systemLocale' is empty
100%
Description
While checking out issue http://forge.typo3.org/issues/32683 on 6.2 I stumbled upon the same issue.
I found out that if you have UTF8Filesystem set to 1, but $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLocale'] is empty, then TYPO3 generate wrong file names, resulting e.g. in thumbnails not being generated in the backend. The problem disappear if I set '['SYS']['systemLocale']' to e.g. 'C.UTF-8' or 'en_US.UTF-8' or similar.
But the issue is not limited to thumbnails ony. It also occurs in many other places. There are plenty of related issues in Forge.
The common pattern all over TYPO3 is sth like this:
if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['UTF8filesystem']) { $currentLocale = setlocale(LC_CTYPE, 0); setlocale(LC_CTYPE, $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLocale']); } //do sth here e.g. basename, escapeshellarg, dirname, pathinfo $escapedInputName = escapeshellarg($inputName); if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['UTF8filesystem']) { setlocale(LC_CTYPE, $currentLocale); }
Btw, there is already a ticket to refactor this and put the logic in the central place. http://forge.typo3.org/issues/39928
I see several solutions here:
1. Use fallback when setting locale.
Instead of
setlocale(LC_CTYPE, $currentLocale);
setlocale(LC_CTYPE, $currentLocale, 'C.UTF-8', 'en_US.utf8');
2. Set default value 'C.UTF-8' to $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLocale'], so it should be never empty.
3. Add install tool warning when systemLocale is not set
4. BTW, why can not we set setlocale() globally in bootstrap instead of setting it for each function separately?