From f2e0a1379dce1045f09076576bf9de819a29b3b1 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Wed, 1 Jun 2022 10:17:49 +0200 Subject: [PATCH 1/2] Add algorithm to extract an encoding from a MIME type This is useful for HTML's fetch a classic script and Fetch's upcoming opaque-response blocking. It will also be useful to more tightly define equivalent legacy setups elsewhere. --- fetch.bs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/fetch.bs b/fetch.bs index 26efa08e2..b9121ffc4 100644 --- a/fetch.bs +++ b/fetch.bs @@ -3491,6 +3491,30 @@ Content-Type: +

To legacy extract an encoding given failure or a MIME type +mimeType and an encoding encoding, run these steps: + +

    +
  1. If mimeType is failure, then return encoding. + +

  2. If mimeType["charset"] does not exist, then return + encoding. + +

  3. Let tentativeEncoding be the result of getting an encoding from + mimeType["charset"]. + +

  4. If tentativeEncoding is failure, then return encoding. + +

  5. Return tentativeEncoding. +

+ +
+

This algorithm allows mimeType to be failure so it can be more easily combined with + extract a MIME type. + +

It is denoted as legacy as modern formats are to exclusively use UTF-8. +

+

`X-Content-Type-Options` header

From 5d92f26678ac17c7f376529510769bddcb964d06 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Wed, 1 Jun 2022 18:30:44 +0200 Subject: [PATCH 2/2] nit --- fetch.bs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fetch.bs b/fetch.bs index b9121ffc4..dfabed5a1 100644 --- a/fetch.bs +++ b/fetch.bs @@ -3492,18 +3492,18 @@ Content-Type:

To legacy extract an encoding given failure or a MIME type -mimeType and an encoding encoding, run these steps: +mimeType and an encoding fallbackEncoding, run these steps:

    -
  1. If mimeType is failure, then return encoding. +

  2. If mimeType is failure, then return fallbackEncoding.

  3. If mimeType["charset"] does not exist, then return - encoding. + fallbackEncoding.

  4. Let tentativeEncoding be the result of getting an encoding from mimeType["charset"]. -

  5. If tentativeEncoding is failure, then return encoding. +

  6. If tentativeEncoding is failure, then return fallbackEncoding.

  7. Return tentativeEncoding.