Project

General

Profile

Actions

Bug #55721

closed

wrong filenames when UTF8filesystem is set and 'systemLocale' is empty

Added by Tymoteusz Motylewski about 10 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2014-02-06
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

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?


Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Task #39928: Central function to correctly (locale-aware) escape filenames and shell-argsClosed2012-08-18

Actions
Related to TYPO3 Core - Bug #32683: showpic.php does not show pics with utf8 in filenamesClosed2011-12-19

Actions
Actions #1

Updated by Markus Klein about 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.

Actions #2

Updated by Jigal van Hemert about 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.

Actions #3

Updated by Gerrit Code Review about 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

Actions #4

Updated by Gerrit Code Review about 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

Actions #5

Updated by Gerrit Code Review about 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

Actions #6

Updated by Gerrit Code Review about 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

Actions #7

Updated by Gerrit Code Review about 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

Actions #8

Updated by Zbigniew Jacko about 10 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #9

Updated by Benni Mack over 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF