Make WordPress Core

Opened 5 months ago

Last modified 5 months ago

#43170 new defect (bug)

Replace all usages of basename() with wp_basename() in order to support multibyte filenames

Reported by: Viper007Bond Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.9.2
Component: Media Keywords: needs-patch
Focuses: Cc:


We still use basename() in a lot of places even though it isn't multibyte compatible out of the box. See http://php.net/basename and https://bugs.php.net/bug.php?id=62119.

Example filename where it can fail: 麻美.jpg

We should replace all uses of basename() with our own wp_basename(). This will probably need a lot of testing, so probably best to avoid one big patch and instead change calls in small chunks.

Related: #43138

Attachments (1)

43170-tests-factory-attachments.patch (1020 bytes) - added by Viper007Bond 5 months ago.
Allow for multibyte filenames in attachment unit tests.

Download all attachments as: .zip

Change History (3)

5 months ago

Allow for multibyte filenames in attachment unit tests.

#1 @Viper007Bond
5 months ago

  • Keywords needs-patch added

The above attached patch is just one example where we need to swap it out. I discovered this when writing a unit test for one of my plugins:


I ended up having to clone self::factory()->attachment->create_upload_object() so that I didn't end up with unnamed-file.jpg.

#2 @SergeyBiryukov
5 months ago

  • Component changed from General to Media

Related: #21217, #23267, #25236, #33227.

Note: See TracTickets for help on using tickets.