Make WordPress Core

Opened 3 years ago

Last modified 3 years ago

#54193 new defect (bug)

PHP fileinfo extention identifies JSON as text/plain; wp_check_filetype_and_ext then prevents upload

Reported by: dashifen's profile dashifen Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Media Keywords: has-patch needs-refresh
Focuses: Cc:

Description

For hosts that make available the PHP fileinfo extension, uploaded files of mime type application/json are identified by that extension as text/plain. Within the wp_check_filetype_and_ext function, it's noted that "a few common file types are occasionally detected as text/plain", but application/json is not listed as one of those common types. For reference, the following types are listed: csv, rtf, tsv, and vtt.

I propose adding application/json to this list. Otherwise, I believe it may be impossible to upload a JSON file on a host that uses this extension.

Attachments (2)

fileinfo-json-fix.diff (386 bytes) - added by dashifen 3 years ago.
54193.patch (292 bytes) - added by aezazshekh 3 years ago.
Added application/json to this list

Download all attachments as: .zip

Change History (4)

#1 @mukesh27
3 years ago

  • Keywords has-patch needs-refresh added
  • Version 5.8.1 deleted

Hi there! thanks for the ticket and patch.

Your patch fileinfo-json-fix.diff removed application/json from the file.

Here are a couple of resources to help you get started creating and submitting a patch:

For creating the patch

  • Checkout the master branch (the images show you are on the 5.8 branch)
  • Sync your copy of master to the upstream wordpress/wordpress-develop repo, i.e. by pulling the latest changes from upstream and then merging these changes into your local copy
  • Add the comment change
  • Then svn diff > 54193.diff to create the patch file
  • Then upload that patch file to this ticket

@aezazshekh
3 years ago

Added application/json to this list

#2 @dashifen
3 years ago

Ugh ... I diffed in the wrong order. 😊

Version 0, edited 3 years ago by dashifen (next)
Note: See TracTickets for help on using tickets.