On 2017-06-13 23:14:49 +0200, Martin Mares wrote: > Using libmagic to detect the MIME type sounds reasonable, but inferring > anything from the file's extension (or lack thereof) sounds not.
I don't think that libmagic is a good idea. It has too many false positives; by that, I mean that it can say that some file has some specific MIME type (e.g. text/x-c) while it is actually just text that may have some lines of C in a small part of it. Many bugs have been reported and most of them are still not fixed. IMHO, the rules should be (step by step): 0. Some Mutt variable may refer to an external program that will determine the MIME type, possibly with a charset, or fail. The expected output should be the same as "file -bi", but an empty output is also possible for a fallback (as the following steps). Execute this program when this variable is defined. Note: though "file -bi" could be used as the default value, I would not recommend it as explained above. 1. If the filename has a known file extension, then deduce the MIME type from it in the usual way (/etc/mime.types system). 2. If the file is valid UTF-8 and contains no blacklisted control characters (to be defined, but this should include null bytes), then MIME type = text/plain. 3. MIME type = application/octet-stream. -- Vincent Lefèvre <vinc...@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)