Problem/Motivation

PHP's basename() does not properly support streams or filenames beginning with a non-US-ASCII character.

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21File%21Fi...

When upload a file with non-US-ASCII character name, the file name is transliterated.
The ajax response use PHP function basename() to return the file name. This will get the mentioned file name incorrect.

Proposed resolution

Use Drupal's FileSystem::basename instead.

Comments

azcomi created an issue. See original summary.

azcomi’s picture

Issue summary: View changes
StatusFileSize
new887 bytes
jungle’s picture

Status: Active » Needs review
jungle’s picture

Issue summary: View changes
StatusFileSize
new745 bytes

Deprecated function: Non-static method Drupal\Core\File\FileSystem::basename() should not be called statically

jungle’s picture

Status: Needs review » Needs work
+++ b/src/Controller/UploadController.php
@@ -65,10 +65,12 @@ class UploadController extends ControllerBase {
+      $file_system = \Drupal::service('file_system');

file_system service should be injected

jungle’s picture

Status: Needs work » Reviewed & tested by the community
Related issues: +#2977463: Allow configuration of dropzonejs timeout, default value causes silent errors.

Let's do it in a separate issue as well

jungle’s picture

Status: Reviewed & tested by the community » Needs review

Sorry, wrong status.

  • jungle committed 8cba97b on 8.x-2.x authored by azcomi
    Issue #3015274 by azcomi, jungle: Issue with filenames beginning with a...
jungle’s picture

Status: Needs review » Fixed

Committed, thanks!

jungle’s picture

Category: Support request » Bug report

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.