craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.22k stars 626 forks source link

Non ascii characters are removed from uploaded filenames #7640

Open piotrpog opened 3 years ago

piotrpog commented 3 years ago

After uploading Craft to new serwer, this probles started to occur. Non ascii characters are removed (not replaced) from uploaded filenames, until ascii character is encountered.

So, ąśźźXół turns into Xół - everything before X gets removed. If convertFilenamesToAscii is set to true, this filename would change to Xol - but everything before X would be removed all the same.

Here is my system info:

PHP version | 7.4.7
-- | --
Linux 4.4.202.core2.42
MySQL 5.7.28
GD 7.4.7
Craft Solo 3.6.7

I also sent you my phpinfo dump on support email.

brandonkelly commented 3 years ago

I’m not able to reproduce this:

Screenshot of an Assets index page in Craft, showing that a file originally named “ąśźźXół.jpg” was renamed to “aszzXol.jpg”, per the convertFilenamesToAscii config setting

What is your user account’s preferred language? That can have an effect on the ASCII character mappings.

piotrpog commented 3 years ago

@brandonkelly I tested both with preffered language and regional options set to english and non english, result is the same.

It worked alright with php 7.2, but this behaviour appeared when i switched to php 7.3 and 7.4. Maybe there is some useful info about server configuration that might cause it in phpinfo dump i sent to support email?

brandonkelly commented 3 years ago

I’m testing with 7.4.

Try this:

> composer require yiisoft/yii2-shell
...
> php craft shell
>>> craft\helpers\StringHelper::toAscii('ąśźźXół')

What does that output?