How to get proper filename sanitizing on upload in TYPO3?

1.5k views Asked by At

When I upload a badly (or "utf8-ly") named file in a fresh TYPO3 7.6 install, I get underscores instead of spelled out special characters.

E.g. the filename Bräm!.png is sanitized to Bra__m_.png. I would expect Braem.png.

The server locale looks fine:

LANG=de_CH.UTF-8
LC_CTYPE="de_CH.UTF-8"
LC_NUMERIC="de_CH.UTF-8"
LC_TIME="de_CH.UTF-8"
LC_COLLATE="de_CH.UTF-8"
LC_MONETARY="de_CH.UTF-8"
LC_MESSAGES="de_CH.UTF-8"
LC_PAPER="de_CH.UTF-8"
LC_NAME="de_CH.UTF-8"
LC_ADDRESS="de_CH.UTF-8"
LC_TELEPHONE="de_CH.UTF-8"
LC_MEASUREMENT="de_CH.UTF-8"
LC_IDENTIFICATION="de_CH.UTF-8"
LC_ALL=

In localConfiguration, we have

'systemLocale' => 'de_CH.UTF-8',

And even, in php.ini, I tried

intl.default_locale = de_CH.UTF-8

Still, no "proper" renaming as I'd expect, renaming the File Bräm!.png to Braem.png or at least Braem_.png.

Where else could I look?

2

There are 2 answers

2
Jigal van Hemert On

From what you describe the name of the file is not encoded in UTF-8 but in a single byte character set (ISO-8859-1 for example). In \TYPO3\CMS\Core\Resource\Driver\LocalDriver::sanitizeFileName() UTF-8 is used if you use it in the backend (same for the old file handling functions).

In that case the "ä" isn't a valid multi-byte UTF-8 character and is thus replace by underscore characters.

8
minifranske On

Make sure [SYS][UTF8filesystem] = true in you LocalConfiguration.php