Make WordPress Core

Opened 4 years ago

Closed 3 years ago

#17117 closed defect (bug) (fixed)

WordPress serves up wrong MIME type for Office 2007 downloads

Reported by: LafayetteNuke Owned by: ryan
Milestone: 3.5 Priority: normal
Severity: normal Version: 3.1
Component: Media Keywords: has-patch commit
Focuses: Cc:


When serving up hosted files for download, WordPress assigns the wrong MIME type for Office 2007. For example, docx files are served up as "application/msword" instead of "application/vnd.openxmlformats-officedocument.wordprocessingml.document"

As a result, browsers end up interpreting the files in different ways. Some, like IE8 on Windows 7 or Safari on Mac OS X 10.6, will add a ".doc" to the end of the file name. Others (Firefox, Chrome) will see the Office 98-2003 MIME type, but keep the existing file name. The iPad displays a "Unknown file type" error. The issue is not limited to Word 2007 files however; all Office 2007 files (pptx, xlsx) appear to have the same issue.

There is a forum discussion for this issue:

It's possible this bug was introduced here:

The proposed change is to tweak the MIME declarations in wp-includes/functions.php to reflect the proper MIME type information.

Attachments (5)

17117-1.patch (886 bytes) - added by hebbet 4 years ago.
with correct name
17117-2.patch (868 bytes) - added by hebbet 4 years ago.
mime.patch (2.7 KB) - added by mohanjith 4 years ago.
Based on /etc/mime.types from Ubuntu 11.04
17117.2.patch (3.5 KB) - added by SergeyBiryukov 3 years ago.
17117.3.patch (6.3 KB) - added by SergeyBiryukov 3 years ago.

Download all attachments as: .zip

Change History (18)

comment:1 @solarissmoke4 years ago

  • Keywords has-patch added

comment:2 @dd324 years ago

Patch looks valid, however, it'd be appreciated if when creating patches, you either use svn diff, or include the full filename in the path of the diff.

This should only be affecting Multisite, as only multisite installs serve files through the File handler (Single sites serve static files directly, and any mime type issues are a server configuration issue)

@hebbet4 years ago

with correct name

comment:3 @hebbet4 years ago

added updated version (hopefully with correct naming). sorry didn't noticed that the name wasn't included.

@hebbet4 years ago

comment:4 @mohanjith4 years ago

  • Cc mohanjith added

Any plans to apply the patch?

@mohanjith4 years ago

Based on /etc/mime.types from Ubuntu 11.04

comment:5 @nacin3 years ago

  • Milestone changed from Awaiting Review to 3.4

mime.patch looks sane.

comment:6 @SergeyBiryukov3 years ago

  • Keywords commit added

comment:7 follow-up: @nacin3 years ago

I see 'sld' added in wp_ext2type() but missing from get_allowed_mime_types().

@SergeyBiryukov3 years ago

comment:8 in reply to: ↑ 7 @SergeyBiryukov3 years ago

Replying to nacin:

I see 'sld' added in wp_ext2type() but missing from get_allowed_mime_types().

I guess it should be 'sldm'. Fixed in 17117.2.patch. Whitespace changes are for better alignment.

comment:9 @ryan3 years ago

  • Milestone changed from 3.4 to Future Release

comment:10 @SergeyBiryukov3 years ago

Related/duplicate: #15735

@SergeyBiryukov3 years ago

comment:11 @SergeyBiryukov3 years ago

Merged with the patch from #15735 (some rearragements and comments for easier reading).

comment:12 @SergeyBiryukov3 years ago

  • Component changed from Filesystem to Media
  • Milestone changed from Future Release to 3.5

comment:13 @ryan3 years ago

  • Owner set to ryan
  • Resolution set to fixed
  • Status changed from new to closed

In [21527]:

Fix MS Office mime types. Group the mime list in get_allowed_mime_types() by type. Props hebbet, markel, SergeyBiryukov. fixes #17117

Note: See TracTickets for help on using tickets.