Skip to content

Commit a4adbda

Browse files
committed
Define parsing for X-Content-Type-Options in detail
And add some of the infrastructure needed to define parsing better for all headers going forward (needed for #814). Fixes #752. This also fixes an issue with CORB as it simply assumed an X-Content-Type-Options was present. Tests: web-platform-tests/wpt#13559.
1 parent daca6a8 commit a4adbda

File tree

1 file changed

+43
-20
lines changed

1 file changed

+43
-20
lines changed

fetch.bs

+43-20
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,16 @@ specialized multimap. An ordered list of key-value pairs with potentially duplic
300300
(<var>name</var>) if <var>list</var> <a for=list>contains</a> a <a for=/>header</a> whose
301301
<a for=header>name</a> is a <a>byte-case-insensitive</a> match for <var>name</var>.
302302

303+
<p>To <dfn export for="header list" id=concept-header-list-get>get</dfn> a <a for=header>name</a>
304+
<var>name</var> from a <a for=/>header list</a> <var>list</var>, run these steps:
305+
306+
<ol>
307+
<li><p>If <var>list</var> <a for="header list">does not contain</a> <var>name</var>, then return
308+
null.
309+
310+
<li><p>Return the <a for="header">combined value</a> with <var>name</var> and <var>list</var>.
311+
</ol>
312+
303313
<p>To <dfn export for="header list" id=concept-header-list-append>append</dfn> a
304314
<a for=header>name</a>/<a for=header>value</a> (<var>name</var>/<var>value</var>) pair to a
305315
<a for=/>header list</a> (<var>list</var>), run these steps:
@@ -368,7 +378,7 @@ a <a for=/>header list</a> (<var>list</var>), run these steps:
368378
<p><a for=list>For each</a> <var>name</var> in <var>names</var>:
369379

370380
<ol>
371-
<li><p>Let <var>value</var> be the <a for=header>combined value</a> given <var>name</var> and
381+
<li><p>Let <var>value</var> be the <a for=header>combined value</a> with <var>name</var> and
372382
<var>list</var>.
373383

374384
<li><p><a for=list>Append</a> <var>name</var>-<var>value</var> to <var>headers</var>.
@@ -2498,7 +2508,32 @@ response <a for=/>header</a> can be used to require checking of a <a for=/>respo
24982508
`<code>Content-Type</code>` <a for=/>header</a> against the <a for=request>destination</a> of a
24992509
<a for=/>request</a>.
25002510

2501-
<p>Its <a for=header>value</a> <a>ABNF</a>:
2511+
<p>To <dfn>determine nosniff</dfn>, given a <a for=/>header list</a> <var>list</var>, run these
2512+
steps:
2513+
2514+
<ol>
2515+
<li><p>Let <var>value</var> be the result of <a for="header list">getting</a>
2516+
`<a http-header><code>X-Content-Type-Options</code></a>` from <var>list</var>.
2517+
2518+
<li><p>If <var>value</var> is null, then return false.
2519+
2520+
<li><p>Let <var>stringValue</var> be the <a>isomorphic encode</a> of <var>value</var>.
2521+
2522+
<li>
2523+
<p>Let <var>tokens</var> be the result of
2524+
<a lt="split on commas">Spliting <var>stringValue</var> on commas</a>.
2525+
2526+
<p class="note">This intentionally strips U+000C FORM FEED, despite 0x0C not being being a
2527+
<a>HTTP whitespace byte</a>.
2528+
2529+
<li><p>If <var>tokens</var>[0] is an <a>ASCII case-insensitive</a> match for
2530+
"<code>nosniff</code>", then return true.
2531+
2532+
<li><p>Return false.
2533+
</ol>
2534+
2535+
<p>Web developers and conformance checkers must use the following <a for=header>value</a>
2536+
<a>ABNF</a> for `<a http-header><code>X-Content-Type-Options</code></a>`:
25022537

25032538
<pre>
25042539
X-Content-Type-Options = "nosniff" ; case-insensitive</pre>
@@ -2510,16 +2545,8 @@ X-Content-Type-Options = "nosniff" ; case-insensitive</pre>
25102545
<p>Run these steps:
25112546

25122547
<ol>
2513-
<li><p>If <var>response</var>'s <a for=response>header list</a>
2514-
<a for="header list">does not contain</a> `<a http-header><code>X-Content-Type-Options</code></a>`,
2515-
then return <b>allowed</b>.
2516-
2517-
<li><p>Let <var>nosniff</var> be the result of <a>extracting header values</a> from the
2518-
<em>first</em> <a for=/>header</a> whose <a for=header>name</a> is a <a>byte-case-insensitive</a>
2519-
match for `<a http-header><code>X-Content-Type-Options</code></a>` in <var>response</var>'s
2520-
<a for=response>header list</a>.
2521-
2522-
<li><p>If <var>nosniff</var> is failure, then return <b>allowed</b>.
2548+
<li><p>If <a>determine nosniff</a> with <var>response</var>'s <a for=response>header list</a> is
2549+
false, then return <b>allowed</b>.
25232550

25242551
<li><p>Let <var>mimeType</var> be the result of <a for="header list">extracting a MIME type</a>
25252552
from <var>response</var>'s <a for=response>header list</a>.
@@ -2578,14 +2605,10 @@ run these steps:</p>
25782605
<var>mimeType</var> (ignoring parameters) is a <a>CORB-protected MIME type</a>, then return
25792606
<b>blocked</b>.
25802607

2581-
<li><p>Let <var>nosniff</var> be the result of <a>extracting header values</a> from the
2582-
<em>first</em> <a for=/>header</a> whose <a for=header>name</a> is a <a>byte-case-insensitive</a>
2583-
match for `<a http-header><code>X-Content-Type-Options</code></a>` in <var>response</var>'s
2584-
<a for=response>header list</a>.
2585-
25862608
<li>
2587-
<p>If <var>nosniff</var> is not failure and <var>mimeType</var> (ignoring parameters) is a
2588-
<a>CORB-protected MIME type</a> or <code>text/plain</code>, then return <b>blocked</b>.
2609+
<p>If <a>determine nosniff</a> with <var>response</var>'s <a for=response>header list</a> is true
2610+
and <var>mimeType</var> (ignoring parameters) is a <a>CORB-protected MIME type</a> or
2611+
<code>text/plain</code>, then return <b>blocked</b>.
25892612

25902613
<p class="note no-backref">CORB only protects <code>text/plain</code> responses with a
25912614
`<code>X-Content-Type-Options: nosniff</code>` header. Unfortunately, protecting such responses
@@ -4893,7 +4916,7 @@ invoked, must run these steps:
48934916
<li><p>If the <a>context object</a>'s <a for=Headers>header list</a>
48944917
<a for="header list">does not contain</a> <var>name</var>, then return null.
48954918

4896-
<li><p>Return the <a for=header>combined value</a> given <var>name</var> and the
4919+
<li><p>Return the <a for=header>combined value</a> with <var>name</var> and the
48974920
<a>context object</a>'s <a for=Headers>header list</a>.
48984921
</ol>
48994922

0 commit comments

Comments
 (0)