Masking in the MIME magic spec

Thomas Kluyver thomas at
Sun Mar 10 05:51:41 PDT 2013

The spec [1] says that the mask is applied to the value from the file
before comparing it with the value from the magic database.

However, looking for examples, I find image/vnd.adobe.photoshop [2], where
bytes 5-6 of the mask are \x00\x00, while bytes 5-6 of the value are
\x20\x20 (two spaces). By my reading, the test is therefore [value & 0x0000
== 0x2020], which can never be true.

It looks like the mask should be applied to both the value from the file
and the value in the magic database, so where the mask is \x00, the magic
value is ignored. This appears to be what xdgmime does [3]. Is this
correct, and is it worth updating the spec to clarify it?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the xdg mailing list