Right way to sniff mimetype from globs

D Bera dbera.web at gmail.com
Sun Oct 21 06:33:26 PDT 2007


Hi,
  We use xdgmime in our application for mimetype detection. With the
latest xdgmime and shared-mime-info, I observe the following (we use a
detection order similar to gnomevfs-info, so thats what I am using for
this example):
$  echo "<html><head></head><body>hello</body></html>" > a.html
$ gnomevfs-info [-s] a.html
Name              : a.html
Type              : Regular
MIME type         : application/x-mozilla-bookmarks
...

which is clearly not right.

This happens because both x-mozilla-bookmarks and text/html match the
glob pattern *.html, x-mozilla-bookmarks is a subclass of text/html
(and maybe also due to higher priority of x-mozilla-boormarks).

So the question is what is the right order of detection ?

I found someone mentioned about this,
> If only one glob matches, use that
>
> If no glob matches, sniff and use that
>
> If several globs matches, and sniffing gives a result we do:
>   if sniffed prio >= 80, use sniffed type
>   for glob_match in glob_matches:
>      if glob_match is subclass or equal to sniffed_type, use glob_match
>
> If several globs matches, and sniffing fails, or doesn't help:
>   fall back to the first glob match

This would have the same problem as above!

The currently running thread "Shared-mime checking order" is possibly
relevant to this question, but its probably dealing with many more
issues. If this has been discussed before, I would appreciate if
someone points me to the right thread. I could not find any.

Thanks,
- dBera

-- 
-----------------------------------------------------
Debajyoti Bera @ http://dtecht.blogspot.com
beagle / KDE fan
Mandriva / Inspiron-1100 user


More information about the xdg mailing list