WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#27495 closed defect (bug) (worksforme)

Multisite SVG uploads are served with incorrect mime/type

Reported by: jhawksley Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Media Keywords: reporter-feedback close
Focuses: multisite Cc:

Description

wp-includes/ms-files.php returns [text/xml] for SVG files, not [image/svg], which breaks their display.

Attachments (1)

Screen Shot 2014-10-03 at 1.34.14 PM.png (5.8 KB) - added by wonderboymusic 5 years ago.

Download all attachments as: .zip

Change History (5)

#1 @johnbillion
5 years ago

  • Component changed from General to Media
  • Focuses accessibility template performance removed
  • Keywords reporter-feedback added
  • Version changed from 3.8.1 to 3.0

Thanks for the report jhawksley, and sorry nobody has gotten back to you until now.

By default, WordPress does not allow SVG files to be uploaded for security reasons. Are you running a plugin which enables SVG files to be uploaded?

If so, it should be hooking into the upload_mimes filter and adding the text/xml mime type in there. Can you confirm whether this is the case please?

#2 follow-up: @jhawksley
5 years ago

That is not the case. Even when setting mime type as image/svg, ms-files.php still sets the header as text/xml.

#3 in reply to: ↑ 2 @SergeyBiryukov
5 years ago

  • Keywords close added

Replying to jhawksley:

That is not the case. Even when setting mime type as image/svg, ms-files.php still sets the header as text/xml.

I could not reproduce this with the code from comment:1:ticket:20990.

ms-files.php uses wp_check_filetype() and falls back to mime_content_type():
tags/3.8.2/src/wp-includes/ms-files.php#L32.

If the correct image/svg+xml type is added via upload_mimes filter, then wp_check_filetype() returns that.

Otherwise, mime_content_type() is used, which depends on server configuration (see comment:10:ticket:25224).

This appears to be a duplicate of #24251 and #26256. See also #25224 and #26591.

#4 @wonderboymusic
5 years ago

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

This works - see image above:

function ___mime_types( $mimes ) {
	$mimes['svg'] = 'image/svg+xml';
	return $mimes;
}
add_filter( 'mime_types', '___mime_types' );
Note: See TracTickets for help on using tickets.