duplicate glob patterns in shared-mime-info
Matthias Clasen
mclasen at redhat.com
Tue Oct 18 08:29:49 PDT 2005
Hey,
I tried to understand what goes wrong with the mime system to make
all .pcf fonts appear as Cisco VPN files in rawhide recently. I found
that somebody added a glob pattern
application/x-cisco-vpn-settings:*.pcf
but freedesktop.org.xml already contained a glob pattern for pcf fonts:
application/x-font-pcf:*.pcf
The way the current implementation (shared-mime-info and xdgmime) handle
duplicate globs is that update-mime-database warns about them and throws
all but the first one away, and xdgmime tries globs first before any
magic, and is satisfied when it finds a match. So for the .pcf pattern
update-mime-database only keeps the cisco-vpn pattern, and xdgmime
happily classifies every .pdf file as cisco-vpn. To fix this (and the
handling of duplicate globs in general), I propose to change the
implementations in the following way:
- update-mime-database should not throw away any glob patterns and
just emit duplicates in the globs files. To handle duplicate glob
patterns in the suffix tree inside the binary cache, we can just store
them as children with a \0 character as follows:
[p]
[c]
[f] - application/x-cisco-vpn-settings
[\0] - application-x-font-pcf
[\0] - some other mime type with glob *.pcf
- xdgmime should recognize if there are multiple mimetypes with the same
glob, and use magic to disambiguate between them.
I'll attach patches for this. While I think they are correct, I would be
much more confident in them if we had a testsuite for the mime system...
Matthias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xdgmime.patch
Type: text/x-patch
Size: 20806 bytes
Desc: xdgmime patch
Url : http://lists.freedesktop.org/archives/xdg/attachments/20051018/87c73aec/attachment.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sharedmime.patch
Type: text/x-patch
Size: 5349 bytes
Desc: shared-mime-info patch
Url : http://lists.freedesktop.org/archives/xdg/attachments/20051018/87c73aec/attachment-0001.bin
More information about the xdg
mailing list