#10067: Extension should determine file type with same sniffer rule
--------------------------------+-----------------------------------
Reporter: humdinger | Owner: bonefish
Type: enhancement | Status: new
Priority: normal | Milestone: R1
Component: Servers/registrar | Version: R1/Package Management
Resolution: | Keywords:
Blocked By: | Blocking: 10917
Platform: All |
--------------------------------+-----------------------------------
Comment (by CodeforEvolution):
In reality, to make this much more simple, we can go with the BeOS route
and have the registrar actually attempt to scan a file's extension first.
This would avoid problems with rar and cbr files, in addition to cases
where source code files (which are just text files with no standard
format) are being mis-mimetyped as just plain text files.
According to https://birdhouse.org/beos/bible/exc_filetype.html:
**Assigning a MIME Type Where There Is None**
When a new file arrives on your system without a MIME type (as happens
when bringing files over to BeOS from other operating systems), the
Tracker and the Registrar work together to assign it one.
The Registrar's first recourse is to look for an extension on the end of
the filename, like .jpg, .txt, or .html. If it finds one, it checks the
FileTypes database to see whether you've connected that extension with any
particular filetype. For example, you may have used the Extensions section
of FileTypes to declare that files ending in .html were likely to be HTML
documents, and that they should inherit the text/html filetype.
If no extension is found, the Tracker will actually read a small portion
of the file with a "sniffer." If it encounters plain text, it will assume
that this is a text document and give it the appropriate MIME type. A
similar process occurs with GIFs, WAVs, and other common filetypes.
Because the extensions technique is more likely to be accurate, it's run
first. Assuming you've set up a few common extensions in your FileTypes
database, BeOS can guess a file's type accurately the vast majority of the
time, with the vast majority of files.
--
Ticket URL: <https://dev.haiku-os.org/ticket/10067#comment:5>
Haiku <https://dev.haiku-os.org>
The Haiku operating system.