This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 19799 - Make sniffing sub-algorithms callable without the main algorithm
Summary: Make sniffing sub-algorithms callable without the main algorithm
Status: RESOLVED FIXED
Alias: None
Product: WHATWG
Classification: Unclassified
Component: MIME (show other bugs)
Version: unspecified
Hardware: PC All
: P1 normal
Target Milestone: Unsorted
Assignee: Gordon P. Hemsley
QA Contact: sideshowbarker+mimespec
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-31 18:55 UTC by Ian 'Hixie' Hickson
Modified: 2012-11-01 15:40 UTC (History)
2 users (show)

See Also:


Attachments

Description Ian 'Hixie' Hickson 2012-10-31 18:55:08 UTC
The HTML spec invokes "rules for distinguishing if a resource is text or binary" directly, so "resource header" isn't defined when the algorithm is invoked.
Comment 1 Gordon P. Hemsley 2012-10-31 19:29:41 UTC
Ah, you're right. I'd tried to avoid that from happening just yet, but it appears I was unsuccessful.

You should map the terms you use as follows:

* "rules for sniffing images specifically" => "media type sniffing algorithm with the 'sniff-images' flag set"
* "rules for distinguishing if a resource is text or binary" => "media type sniffing algorithm with the 'sniff-text-or-binary' flag set"
Comment 2 Ian 'Hixie' Hickson 2012-10-31 22:23:13 UTC
Why? That seems... less clear. All it does is add an extra level of indirection. Also it is inefficient, e.g. the <object> algorithm only calls the "text or binary" algorithm if the type is known to be text/plain, at which point why would we want to go through the algorithm that checks the octets again? That wouldn't get the right effect (e.g. if it's TEXT/PLAIN). The whole point is to skip that check.
Comment 3 Gordon P. Hemsley 2012-11-01 15:03:29 UTC
(In reply to comment #2)
> Why? That seems... less clear. All it does is add an extra level of
> indirection. Also it is inefficient, e.g. the <object> algorithm only calls
> the "text or binary" algorithm if the type is known to be text/plain, at
> which point why would we want to go through the algorithm that checks the
> octets again? That wouldn't get the right effect (e.g. if it's TEXT/PLAIN).
> The whole point is to skip that check.

I see; I wasn't familiar with how you were invoking the algorithm.

I'll fix it so that it can do both. (See also bug 19802 comment 3.)
Comment 4 Gordon P. Hemsley 2012-11-01 15:40:59 UTC
I've abstracted the definitions of "resource header" and "read the resource header" out of the main sniffing algorithm:

https://github.com/whatwg/mimesniff/commit/8fd3b5e2d026df7ac2748f6049e8707ab0efe934

I believe this fixes the problem; if it doesn't, reopen the bug.