Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 2 years ago

#47448 closed defect (bug) (duplicate)

CSV import MIME type fails with HTML content

Reported by: netweblogic's profile netweblogic Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.3
Component: Upload Keywords:
Focuses: Cc:


Related to #45615 which is not fully resolved.

I've noticed that with CSV uploads, if a CSV contains HTML (which is valid content for a CSV file), the MIME type in the following function gets returned as 'text/html':

$real_mime = finfo_file( $finfo, $file );

Here's a simple CSV file sample that demonstrates the problem. Try uploading that to media and you get

Sorry, this file type is not permitted for security reasons.

"John","Smith","1980-01-01","<a href="""">WordPress</a>"

Remove the HTML in there, and it uploads without issue. I think CSV should permit text/html as well as a valid mime type.

Attachments (1)

random.csv (111 bytes) - added by netweblogic 4 years ago.
Example CSV file that'll fail to get uploaded.

Download all attachments as: .zip

Change History (4)

4 years ago

Example CSV file that'll fail to get uploaded.

#1 @SergeyBiryukov
4 years ago

  • Component changed from General to Upload

#2 @andraganescu
4 years ago

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

Duplicate of #40175.

Hi there,

This problem with detecting the correct mime of files is being already tracked in and the solution which will be found there will address this too. Therefore I will close this as duplicate of that ticket.

Thank you!

This ticket was mentioned in Slack in #core-media by antpb. View the logs.

2 years ago

Note: See TracTickets for help on using tickets.