Make WordPress Core

Opened 10 days ago

Last modified 32 hours ago

#61948 assigned defect (bug)

Uploading WAV files fail in Gutenberg editor on Firefox browser when drag-dropped

Reported by: imranh920's profile imranh920 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch
Focuses: Cc:

Description

When uploading WAV audio files by drag-dropping, it fails in Firefox, but works as without issue on Chrome and other browsers. This issue doesn't happen for other media or audio formats.

Attachments (1)

61948.diff (655 bytes) - added by imranh920 10 days ago.

Download all attachments as: .zip

Change History (5)

@imranh920
10 days ago

This ticket was mentioned in PR #7265 on WordPress/wordpress-develop by @imranh920.


10 days ago
#2

  • Keywords has-patch added

Farther details can be found here https://github.com/Automattic/wp-calypso/issues/93778 .

When we upload the wav file here, Chrome and all other browsers identify the mimetype of the file to be audio/wav, but Firefox, identifies the mimetype as audio/x-wav.

WordPress core has a default (extensible) set of mime-type that it allows uploading. You can find them here https://github.com/WordPress/wordpress-develop/blob/3b1e57752d5dd737477873b6797e3f8209aec078/src/wp-includes/functions.php#L3392-L3513 . You’ll notice that there is the audio/wav mime-type there, but not audio/x-wav.
So when Gutenberg tries to check the mimetype of the file in Firefox here https://github.com/WordPress/gutenberg/blob/5773ae60ca33bda03f2a35e6707d961b8db3af18/packages/media-utils/src/utils/upload-media.js#L91-L118, it sees that the mime-type (audio/x-wav) isn’t one of the allowed ones.
So it throws an error.

Here we are including the x-wav mime type.

Before applying this patch -

  • Use Firefox browser
  • Open a page or a post in Gutenberg editor.
  • Try to drag and drop this WAV file in the editor https://tinyurl.com/24tkan96
  • You should see an error like below

https://github.com/user-attachments/assets/d5a47f79-aa6e-417a-a7e5-93203cad38e3

After applying this patch -

  • Try to do the same drag-and-drop operation as before
  • You should not see an error this time
  • Also try the same in Chrome and other browsers, make sure no error is thrown
  • Try uploading this file in Media Uploader and make sure no error is thrown
  • Try with other wav files and media files too

Trac ticket: https://core.trac.wordpress.org/ticket/61948

#4 @miguelsansegundo
32 hours ago

Nice find!
I tested this small change and fixes the issue.

Note: See TracTickets for help on using tickets.