On Apr 18, 2017, at 8:07 PM, The Tick <the.t...@gmx.com> wrote:
> 
> I added this patch:
> 
> --- doc.c.orig  2017-03-10 11:07:08.000000000 -0600
> +++ doc.c       2017-04-17 23:32:03.770418400 -0500
> @@ -49,6 +49,7 @@
>     { "\211PNG\r\n\032\n",       8, "image/png"  },
>     { "\377\332\377",            3, "image/jpeg" },
>     { "\377\330\377",            3, "image/jpeg" },
> +    { "\0\0\1\0",                4, "image/x-icon" },
>   };
> 
>   if( !looks_like_binary(pBlob) ) {
> 
> 
> Now >my< version of fossil show the ICO file also. (I say this patch is 
> incomplete because definitively identifying an ICO file is more that just 
> looking at the first 4 bytes).

Both file(1) magic files I looked at here pretty much just do that.  (CentOS 
and FreeBSD.)  There are elaborations, but they seem entirely concerned with 
parsing out internal details, not making detection more reliable.

I’d call your patch “close enough.”  It’s only got a 1 in 4 billion chance of 
matching something incorrectly for a uniform probability distribution, and a 
much smaller chance than that in practice given the bias towards text file 
types in Fossil repositories.

> My idea was to have a way to specify the mime type on a per-file basis. Or 
> maybe by file extension like the 'encoding-glob', etc. settings?

So far, the one-off policy works pretty well, since typical web browsers don’t 
add new internally-viewable file types that often.  With this move away from 
plugins, the list of viewable file types may be *shrinking* at the moment.

I’m not rejecting the idea, I’m just calling into question its ROI.

How about if Fossil just loads the platform MIME type DB and uses that?  Many 
*ix type platforms have one, such as CentOS’s /etc/mime.types or FreeBSD’s 
/usr/local/share/mime/globs.

Writing the parsers would be a bit more work than just cloning the *-glob 
infrastructure and injecting the results into src/doc.c, but it would mean 
Fossil wouldn’t have to adjust its internal DB ever again.

The only open question in my mind is what to do on Windows?  IIS must have such 
a DB, but how does a program access it?
_______________________________________________
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

Reply via email to