whatwg / mimesniff

MIME Sniffing Standard

Home Page:https://mimesniff.spec.whatwg.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

6.2.2. Signature for WebM will always return false.

jyavenard opened this issue · comments

What is the issue with the MIME Sniffing Standard?

In its current state, the Signature for WebM algorithm will always return false.
https://mimesniff.spec.whatwg.org/#signature-for-webm

current step 6 reads:

6. While iter is less than length and iter is less than 38, continuously loop through these steps:
  1. If the two bytes from sequence[iter] to sequence[iter + 1] are equal to 0x42 0x82,
    1. Increment iter by 2.
    2. If iter is greater or equal than length, abort these steps.
    3. Let number size be the result of [parsing a vint](https://mimesniff.spec.whatwg.org/#parse-a-vint) starting at sequence[iter].
    4. Increment iter by number size.
    5. If iter is less than length - 4, abort these steps.
    6. Let matched be the result of [matching a padded sequence](https://mimesniff.spec.whatwg.org/#matching-a-padded-sequence) 0x77 0x65 0x62 0x6D ("webm") on sequence at offset iter.
    7. If matched is true, abort these steps and return true.
  2. Increment iter by 1.
7. Return false.

at step 6.1.5 If iter is less than length - 4, abort these steps. this condition will normally always be true: we have not iterated to the end of the file yet, so iter will always be less than length - 4

it should read:
If iter is greater than length - 4, abort these steps.