Jump to content

Topic on Project:Support desk

OFT file extension does not match the detected MIME type

6
Summary by Rehman

Resolved. To enable oft uploads, /includes/libs/mime/mime.types should be modified from application/sla stl to application/sla stl oft, in addition to adding .oft files to the list of supported extensions ($wgFileExtensions).

Rehman (talkcontribs)

Hello. On my private wiki, I have enabled the uploading of Microsoft Outlook 2016 Email Templates (.oft) using $wgFileExtensions. But when uploading an oft file, I'm faced with the error File extension ".oft" does not match the detected MIME type of the file (application/sla). Is there a way to fix or overcome this? Or perhaps a way to skip MIME checks for oft files? It may be worth mentioning that the .oft email template contains a PDF attachment. Thanks for any help.

Ammarpad (talkcontribs)
Rehman (talkcontribs)

Thanks for the reply @Ammarpad. I would like to disable MIME type check only for .oft files. Is that possible? If so, would you be able to help me with the code for that please?

Ammarpad (talkcontribs)

I am not sure, but on quick look it seems not possible**. You should either opt for verification or not. You can of course also add the type to the file for $wgMimeTypeFile so that the verification will pass. For me, that seems more effective and simple thing to do.

**By 'not possible' I mean there's no easy way to do this, since there's no hook that trivially allows that, and I don't think you'd want maintain a hacked local copy of UploadBase.php.

Rehman (talkcontribs)

Oh okay. How do I add the type to the file?

Rehman (talkcontribs)

After reading further, I finally found a non-hacky solution to allow uploads of .oft files:

  1. If not already done, add .oft files to the list of supported extensions ( $wgFileExtensions)
  2. In MediaWiki 1.34.2, edit /includes/libs/mime/mime.types and modify application/sla stl to application/sla stl oft. (As far as I know, this directory is changed for 1.35+)

That's it. Without lowering and amending security, I can now upload .oft files.

Hope this helps others struggling with this.