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?
Updated by Markus Klein over 10 years ago
For 6.2 I'd go for 2 and 3 (in case somebody set it to empty again)
4: good question, I'd like to know as well.
Updated by Jigal van Hemert over 10 years ago
1. Which locale as fallback? There are about a zillion locales with different names on different OSs. There no reliable, cross platform way to detect available locales.
2. Same story: which locale as default?
3. Good idea to add a check, but also check if the locale can in fact be used (= is available on the system)
4. In frontend context the locale for LC_TYPE is set according to the TS value in config.locale_all. This is not necessarily one that can be used for file system operations that need a locale. That's the reason for the locale swapping.
Updated by Gerrit Code Review over 10 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27510
Updated by Gerrit Code Review over 10 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27510
Updated by Gerrit Code Review over 10 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27510
Updated by Gerrit Code Review over 10 years ago
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27510
Updated by Gerrit Code Review over 10 years ago
Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/27510
Updated by Zbigniew Jacko over 10 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset df2ebf289696825af67be4fd9a5916f61171f0df.