Skip to content

Commit 82bb961

Browse files
authored
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.
1 parent 4128e96 commit 82bb961

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

fetch.bs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3491,6 +3491,30 @@ Content-Type:
34913491
</table>
34923492
</div>
34933493

3494+
<p>To <dfn export>legacy extract an encoding</dfn> given failure or a <a for=/>MIME type</a>
3495+
<var>mimeType</var> and an <a for=/>encoding</a> <var>fallbackEncoding</var>, run these steps:
3496+
3497+
<ol>
3498+
<li><p>If <var>mimeType</var> is failure, then return <var>fallbackEncoding</var>.
3499+
3500+
<li><p>If <var>mimeType</var>["<code>charset</code>"] does not <a for=map>exist</a>, then return
3501+
<var>fallbackEncoding</var>.
3502+
3503+
<li><p>Let <var>tentativeEncoding</var> be the result of <a for=/>getting an encoding</a> from
3504+
<var>mimeType</var>["<code>charset</code>"].
3505+
3506+
<li><p>If <var>tentativeEncoding</var> is failure, then return <var>fallbackEncoding</var>.
3507+
3508+
<li><p>Return <var>tentativeEncoding</var>.
3509+
</ol>
3510+
3511+
<div class=note>
3512+
<p>This algorithm allows <var>mimeType</var> to be failure so it can be more easily combined with
3513+
<a>extract a MIME type</a>.
3514+
3515+
<p>It is denoted as legacy as modern formats are to exclusively use <a for=/>UTF-8</a>.
3516+
</div>
3517+
34943518

34953519
<h3 id=x-content-type-options-header>`<code>X-Content-Type-Options</code>` header</h3>
34963520

0 commit comments

Comments
 (0)