Skip to content

[web-api] MIME type check in "compile a potential WebAssembly response" imprecise and ambiguous #1138

@domenic

Description

@domenic
  1. Let mimeType be the result of extracting a MIME type from response’s header list.

  2. If mimeType is not application/wasm, reject returnValue with a TypeError and abort these substeps.

Here mimeType is a MIME type record, as returned by extract a MIME type.

However in step 3 it's compared against a byte sequence.

It's unclear how to interpret the intended check here:

  • Do you want to get the raw value of the Content-Type header and check that against the byte sequence? In this case application/wasm; would not match.
  • Do you want to serialize the MIME type and compare it against the string (not byte sequence) "application/wasm"? In this case application/wasm; would match, as would    application/wasm   .
  • Do you want to check against the MIME type's essence? In that case application/wasm;foo=bar would match.
  • Note that for any case except getting the raw value of the Content-Type header, using the "extract a MIME type" algorithm means that multiple headers (or, equivalently, one header with comma-separate values) will be treated forgivingly. E.g. application/javascript, application/wasm and application/wasm, unparseable would both end up as application/wasm.

https://github.com/web-platform-tests/wpt/blob/master/wasm/webapi/contenttype.any.js seems to pick "check the raw value of the Content-Type header".

/cc @surma @annevk

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions