[imps] content type sniffing - unknown type

Ryan King ryan at theryanking.com
Fri Jul 11 18:06:30 PDT 2008


I'm working on a content type sniffing implementation based on the  
current spec, that will eventually make it into html5lib (its part of  
a separate project for now).

Anyway, in "2.7.4 Content-Type sniffing: unknown type", i think  
there's a few things flipped around. Where is says "Examine the  
index<sub>stream</sub>th byte of the byte stream as follows:", i think  
it should actually be referring to the to the index<sub>pattern</ 
sub>th byte of the pattern.

The I understand the algorithm is like this:

  walk through the pattern
   if we're at a WS byte
     consume all the whitespace
   else
     do the 'and' operation with the mask and test it against  
pattern[index<sub>pattern</sub>]
  if we made it through without a mis-match, return the given type.

Implementing it this way has yielded the expected results (ie, the  
examples given in the comments work).

-ryan



More information about the Implementors mailing list