On Wednesday 20 May 2009, Alexander Larsson wrote: > I got a bug report[1] recently about a problem with case insensitive > globs. > > The spec has this to say: > Applications MUST first try a case-sensitive match, then try again with > the filename converted to lower-case if that fails. This is so that > main.C will be seen as a C++ file, but IMAGE.GIF will still use the > *.gif pattern. > > Now, take the case of foo.ps.gz, foo.PS.GZ, and foo.PS.gz. > The first matches .ps.gz and .gz case sensitively, picking the longer > match.The second one does the same, but case insensitively. > The third one however, matches .gz case insensitively only, so picks > that instead of trying an insensitive match...
Ouch, indeed. $ kmimetypefinder foo.ps.gz application/x-gzpostscript $ kmimetypefinder foo.PS.gz application/x-gzip > Not sure how to handle this. Maybe we should always do the insensitive > match What was the use case for case-sensitive matches? Looking at the globs file... Ah, I see one use case for it: *.C (text/x-c++src) vs *.c (text/x-csrc). > and handle conflicts like we do multiple globs with the same > extension? I don't think this would work. What we do is: " 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 But we lose the information that *.C matched and not *.c, therefore we are looking at a random c-or-c++ file so adjusting glob priorities wouldn't help, and sniffing doesn't help with such files either. Seems to me that we should instead introduce an attribute for case-sensitivity: <glob pattern="*.C" case-sensitive="true"/> and do everything else case-insensitively. -- David Faure, [email protected], sponsored by Qt Software @ Nokia to work on KDE, Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org). _______________________________________________ xdg mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/xdg
