This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
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.
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"
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.
(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.)
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.