Closed Bug 1216822 Opened 4 years ago Closed 4 years ago

Make sure that using an invalid Content-Type when constructing a Response object doesn't throw

Categories

(Core :: DOM: Service Workers, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla44
Tracking Status
firefox44 --- fixed

People

(Reporter: ehsan, Unassigned)

References

Details

Attachments

(1 file)

No description provided.
Blocks: 1189023
Hmm, it seems to me this should throw:

  resolve(new Response(new Blob([],{type: 'a\0b'})));

Per step 2 of the append algorithm:

  https://fetch.spec.whatwg.org/#concept-headers-append

The Response constructor doesn't say anything special about ignoring thrown exceptions in step 7.4:

  https://fetch.spec.whatwg.org/#dom-response

It just says:

  "If Content-Type is non-null and r's response's header list contains no header named `Content-Type`, append `Content-Type`/Content-Type to r's response's header list."

Anne, do agree this code should throw?  The test is written such that it expects the error to be silently ignored.
Flags: needinfo?(annevk)
Per the specification it should currently not throw since it uses an internal append that does not do any kind of validation.

Per https://w3c.github.io/FileAPI/#constructorBlob that is possible since \0 should never become part of Blob's type.
Flags: needinfo?(annevk)
Comment on attachment 8676561 [details] [diff] [review]
Make sure that using an invalid Content-Type when constructing a Response object doesn't throw

Review of attachment 8676561 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks Anne.  Patch looks good.
Attachment #8676561 - Flags: review?(bkelly) → review+
https://hg.mozilla.org/mozilla-central/rev/2e4faf57a03b
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla44
You need to log in before you can comment on or make changes to this bug.