Make WordPress Core

Opened 6 years ago

Closed 5 years ago

#44156 closed defect (bug) (invalid)

REST API: Media uploads ignore CJK/emoji chars in filenames

Reported by: 0mirka00's profile 0mirka00 Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.9.6
Component: REST API Keywords:
Focuses: Cc:


When creating a new media item through the media endpoint, CJK and emoji characters in the payload file's name are not correctly set as the title of the resulting media file.

While explicitly supplying the CJK filename as a title argument works as expected, this is not necessary with non-CJK filenames.

The GUI uploader (media-new.php) handles CJK filenames correctly.

Steps to reproduce:

  1. POST a file with filename 日本語.mp3 to /wp/v2/media

Result: title: {raw: "", rendered: ""}

Expected result:title: {raw: "日本語", rendered: "日本語"}

Change History (2)

#1 @kadamwhite
6 years ago

@0mirka00 I am unable to reproduce this issue. Could you provide more information about your environment -- WordPress version, operating system, browser, server information, information about the client or mechanism you are using to POST the file?

I was able to correctly upload a media file using both the wpapi JS library, and via curl. Tested commands:

const path = require( 'path' );
const WPAPI = require( 'wpapi' );

const site = new WPAPI( {
  endpoint: 'http://core.local/wp-json',
  username: 'admin',
  password: 'password',
} ); path.join( __dirname, '時間.jpg' ) ).create().then( resp => console.log( resp ) );
curl --user admin:password -F 'file=@/home/kadam/tmp/バグ.mp3' http://core.local/wp-json/wp/v2/media

Japanese filenames were correctly passed into the returned title field for both JPG and MP3 payloads, tested with both kanji and katakana in the file name.

A potential related issue I saw was that uploading an MP3 caused the creation of an untitled image containing the cover art of the uploaded MP3. This did not happen after renaming the same MP3 using a non-CJK filename. Have you observed anything of this sort on your side?

#2 @kadamwhite
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

I attempted to verify this issue again today, and it works as expected (the title is correctly populated) on all environments in which I have tested. @0mirka00 I am going to close this ticket as invalid, based on my testing, but I'd encourage you to comment below if you are in fact still experiencing this problem.

Note: See TracTickets for help on using tickets.