[haiku-bugs] Re: [Haiku] #10067: Extension should determine file type with same sniffer rule

  • From: "Haiku" <trac@xxxxxxxxxxxx>
  • To: undisclosed-recipients: ;
  • Date: Sat, 02 Jan 2021 18:51:22 -0000

#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 pulkomandy):

 There isn't a "decisive enough" threshold. Each MIME sniffing rule comes
 with a score, the matching rule with the highest score wins.

 Interestingly, there is no rule for "text/plain" so I don't know how your
 file end up being opened by StyledEdit, unless something else sets the
 file type?

 So, I see two possible ways to go about this:
 - Use the extensions only if no rule matched, as a fallback,
 - Factor in the file extensions as an extra hint for the sniffing rules,
 and somehow allow them to adjust their score according to the extension

 The latter seems better for the original problem in this ticket, where we
 have multiple rules matching the content, and use the extension to decide
 between them. The former would be better in your case, where there is no
 matching rule at all and we would then rely only on the file extension.
-- 
Ticket URL: <https://dev.haiku-os.org/ticket/10067#comment:11>
Haiku <https://dev.haiku-os.org>
The Haiku operating system.

Other related posts: