craftcms / cms

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

[4.x]: Craft reports "unable to check if the file exists" when uploading files with BOM characters in file name #13022

Closed jamiewhitemccann closed 1 year ago

jamiewhitemccann commented 1 year ago

What happened?

Description

If we upload assets into Craft CMS that contain BOM (https://en.wikipedia.org/wiki/Byte_order_mark) characters at the end of the file name, then with debug mode enabled, we get the error message:

"unable to check if the file exists"

If the user does not have developer mode enabled, then they get the error message:

"A server error occurred"

Steps to reproduce

  1. Navigate to /admin/assets
  2. Attempt to upload an image with BOM characters, example: Manal-al-Sharif
  3. See one of the above error messages depending on your user settings

Expected behavior

We expected Craft CMS to clean these gremlin characters and upload these files, or at least provide a more user friendly error message for admin users if this is problematic or not possible.

Actual behavior

Confusing error message that required us to debug this issue and work around this by renaming these files and uploading for our client.

Craft CMS version

4.4.4

PHP version

8.0

Operating system and version

Debian GNU/Linux 10 (buster) (Azure App Service Linux)

Database type and version

MySQL 8.0

Image driver and version

imagick module version 3.7.0

Installed plugins and versions

    "craftcms/azure-blob": "2.0.0",
    "craftcms/feed-me": "5.1.1",
    "craftcms/redactor": "3.0.4",
    "nystudio107/craft-retour": "4.1.11",
    "nystudio107/craft-seomatic": "4.0.22",
    "nystudio107/craft-similar": "4.0.0",
    "sebastianlenz/linkfield": "2.1.5",
    "topshelfcraft/wordsmith": "4.2.0",
    "verbb/navigation": "2.0.17",
    "verbb/super-table": "3.0.7",
    "verbb/tablemaker": "4.0.4",
    "vlucas/phpdotenv": "5.5.0",
    "yiisoft/yii2-redis": "2.0.18"
i-just commented 1 year ago

Hi, thanks for reporting! I submitted a PR to adjust this.

brandonkelly commented 1 year ago

This is fixed for the next Craft 3 and 4 releases, via #13029 and #13028.

brandonkelly commented 1 year ago

Craft 3.8.6 and 4.4.6 are out with that fix 🎉