Skip to content

Media Inserter: Decode the filename in the audio preview - #86384

Closed
lazerg wants to merge 1 commit into
WordPress:trunkfrom
lazerg:fix/issue-86380-audio-preview-filename
Closed

lazerg wants to merge 1 commit into
WordPress:trunkfrom
lazerg:fix/issue-86380-audio-preview-filename

Conversation

@lazerg

@lazerg lazerg commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

What?

Closes #86380

Show the decoded filename in the media inserter's audio preview, so a file like 生成波の音1.mp3 shows up as is instead of %E7%94%9F%E6%88%90....

Why?

FilePreview takes the name from getFilename( url ), which reads it from URL.pathname. The pathname is always percent-encoded, so any non-ASCII filename came out as an encoded string, and the long result got truncated too.

How?

Pass the filename through safeDecodeURIComponent before rendering it. If decoding fails, the encoded name is still shown as before.

Testing Instructions

  1. Upload an audio file with a non-ASCII name, e.g. 生成波の音1.mp3.
  2. In a post, open the inserter and go to Media > Audio.
  3. The preview should show 生成波の音1.mp3.

Use of AI Tools

Claude Code helped write the fix.

@lazerg
lazerg requested a review from ellatrix as a code owner November 5, 2026 15:10
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

🎉 Props

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @lazerg.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: lazerg.

Co-authored-by: im3dabasia <im3dabasia1@git.wordpress.org>
Co-authored-by: nendeb <nendeb55@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

@github-actions github-actions Bot added the [Package] Block editor /packages/block-editor label Nov 5, 2026
@lazerg

lazerg commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

I don't have permission to add labels here, could someone add [Type] Bug? Thanks.

@lazerg

lazerg commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

The Playwright failure is the WebKit drag selection test in multi-block-selection.spec.js. It is a known flake and my change doesn't touch it.

@im3dabasia im3dabasia added the [Type] Bug An existing feature does not function as intended label Nov 6, 2026
@im3dabasia

Copy link
Copy Markdown
Contributor

Thanks for contributing, @lazerg! Closing this in favour of #86422, which fixes it inside getFilename() so every place using it gets the decoded name. Your review there would be very welcome. 🙏

@im3dabasia im3dabasia closed this Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block editor /packages/block-editor [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Japanese filenames are incorrectly displayed in the audio preview in the block editor

2 participants