Bug 12541

Summary: audio/x-wav and video/x-msvideo have conflicting magic
Product: shared-mime-info Reporter: Sebastian Dröge (slomo) <slomo>
Component: freedesktop.org.xmlAssignee: Jonathan Blandford <jrb>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium CC: slomo
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Sebastian Dröge (slomo) 2007-09-23 23:53:45 UTC
Quoting http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=443772:

A WAV file matches audio/x-wav but also video/x-msvideo (both are defined at priority 50 in /usr/share/mime/magic). 

If I use xdgmime (cvs version) to detect mimetypes *only* with magic numbers (without globs), I get no mimetype at all because the lookup function in xdgmimemagic.c detects multiple mime types with same priority and can't make a decision (the result is discarded: see xdgmimemagic.c:685)

I suppose that tools based on xdgmime (gnome-vfs for example) suffer the same problem but I didn't checked.

I solved the pb easily by adjusting video/x-msvideo magic priority to 49 in /usr/share/mime/packages/freedesktop.org.xml and running update-mime-database.

Perhaps another way to workaround the pb is to make video/x-msvideo match "RIFF" *AND* "AVI" (instead of "RIFF" or "AVI" as stated in xml file line 15516)

Finally, even if I found a workaround or two, I don't know if it's an upstream bug or not. Both the magic
file and the source code to use it are involved. The specification doesn't give a detailed magic matching algorithm...
Comment 1 Sebastian Dröge (slomo) 2007-09-24 00:01:07 UTC
The problem is, that both wav and msvideo (aka avi) have "RIFF" at byte 0. They only differ afterwards, i.e. have "WAVE" at byte 8 for wav and "AVI" at byte 8 for msvideo.

Same applies to audio/x-riff as it also has "RIFF" in the magic list.
Comment 2 Bastien Nocera 2008-04-10 08:07:05 UTC
I couldn't reproduce the bug before, but I made the changes to require both the RIFF and AVI bits for AVI files.

* freedesktop.org.xml.in: Require AVI files to have both the RIFF
and the "AVI " bits, not just one of them (Closes: #12541)
* tests/list:
* tests/test.avi:
* tests/test.wav: Add WAVE and AVI test files

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.