Shared-mime checking order

Daniel Leidert daniel.leidert.spam at gmx.net
Mon Sep 17 17:05:33 PDT 2007


Am Dienstag, den 18.09.2007, 00:51 +0200 schrieb David Faure:
> On Tuesday 28 August 2007, Alexander Larsson wrote:
> > If several globs matches, and sniffing fails, or doesn't help:
> >   fall back to the first glob match 
> >   (maybe we should do something better here?)
> 
> Hmm, I just found the case of "README.txt", which could either be "text/plain" due to *.txt
> or "text/x-readme" due to README*. Which one should we pick?

text/x-readme

because it's more specific. text/x-readme is defined as sub-class of
text/plain. So it's IMHO natural, that files of the type text/x-readme
can have the same extension as "pure" text/plain files.

> The second pattern "looks"
> more specific to my eyes so it should probably win, but how should we quantify that?
> Should we take the longest pattern?

Not sure, how to implement this.

But I would like to raise a different issue: Let's take the above
example and let's say, that I define a very specific MIME type 

  <mime-type type="text/x-mytest-one">
    <comment>My test case one</comment>
    <glob pattern="README.txt"/>
    <sub-class-of type="text/plain"/>
    <magic priority="100">
      <match value="mystring" type="string" offset="0"/>
    </magic>
  </mime-type>

which MUST have the string "mystring" at offset 0. Now I create a
README.txt file with the content "blah" - definitely not of type
text/x-mytest-one then. But gnomefs-info reports in both modes, that the
file is of type text/x-mytest-one (because I don't have a KDE4
installed, I cannot test your solution David). So: Is it possible to
assign an extra mode, if the priority is 100 or very high, so only if
the magic pattern matches (too), the MIME type can be of this type -
maybe only do this in slow mode - or change the checking order in slow
mode to follow the spec, which IMHO would fix this problem too. But
maybe you have a better idea. I didn't read all the mails (I was busy
the last weeks), but I will do soon - maybe this problem was discussed
in a different mail.

Regards, Daniel



More information about the xdg mailing list