Le Sat, Apr 26, 2025 at 08:20:08PM +0200, Simon Josefsson a écrit :
> 
> Is /etc/mime.types still the state of the art for MIME mappings, or should
> applications better use some other method?

Hi Simon,

using /etc/mime.types is not the state of the art for detecting the media type
of a file.  It is quite ancient and tools that use it tend to rely on the fact
that it is not going to evolve.  For this reason the following limitations are
unlikely to be addressed:

 - there is an implicit promise that there will be no file extension duplicates.
 - case-sensitivity of file extensions is not specified.
 - alternatives to file extensions for media type detection are not provided.

By the way, the media-types package that distributes /etc/mime.types (and
nothing else), is Priority: standard and therefore software that use
unconditionally must depend on it.

There are two main alternatives:

 - the file command and its libmagic library, which can probe a file's contents
   for magic numbers and more complex patterns.

 - the xdg-mime that queries the shared-mime-info database for file extension
   and magic number matches.

What /etc/mime.types provides that the two alternatives do not is the
exhaustive list of IANA-approved media types including those that are not
declaring an extension.  I do not know how useful it is and would be pleased
to hear about applications.  (Because maintaining that list is tedious).

In conclusion, my advice is not not use /etc/mime.types unless the alternatives
have serious drawbacks.

Have a nice day,

-- 
Charles Plessy                         Nagahama, Yomitan, Okinawa, Japan
Debian Med packaging team         http://www.debian.org/devel/debian-med
Tooting from home                  https://framapiaf.org/@charles_plessy
- You  do not have  my permission  to use  this email  to train  an AI -

Reply via email to