Advanced

Fixing OpenDocument MIME magic on Linux

Posted by Sander_Marechal on · 8 comments
Lone Wolves; By Sander Marechal, The Netherlands
Mail this story
Print this story

When working on the beta of Officeshots.org I ran into an interesting problem with file type and MIME type detection of OpenDocument files. When a user uploads an ODF file to Officeshots I want to determine the MIME type myself using the PHP Fileinfo extension. On Linux, the PHP Fileinfo extension relies on the magic file that is provided by the file package. The magic file contains a series of tests that can determine the file type and MIME type of a file by its contents. I found out that the magic file is incomplete for OpenDocument files. In this article I will show you what is wrong with the magic file and how you can fix it.

Full Story

  Nav
» Read more about: Story Type: Tutorial; Groups: Linux, PHP

» Get new stories by e-mail: nightly or as they are published

« Return to the newswire homepage

Comments (8)

Nice bit of debugging, Sander, and a fix! Well done.
Thanks. It has been reported to Debian as well of course: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=525979

As a Debian user, Thank You.
I have updated the article with a patch against the original, upstream file-5.0.3 which had the same problem. That should be useful for those of you who don't use Debian.

Patch here: http://www.jejik.com/files/examples/file-5.0.3-opendocument....
I just got mail that the patch has been committed to the upstream file package. So, it should appear in a new distro near you soon :-)

http://mx.gw.com/pipermail/file/2009/000399.html
Wow, that was fast. I make myself a root beer float in your honor :)
*POOF* you're a root beer? How did you do that?

And can you still type?
Duh. Multi-talented Renaissance root beer.

Post a comment

A free account is needed to post. Write your comment here first: your text is kept in this browser while you sign up or log in, and is waiting for you when you come back.

Your message:
|||||
10
Markdown: **bold**, *italic*, [text](https://link), - lists, > quotes, $x^2$ for math. Formatting help

Sign up and post (it is free)  or  Log in and post