Skip to content

Commit a876e5d

Browse files
committed
Align redirect fragment handling with HTTP
This clarifies how fragment conflicts between the request's current URL and the Location header are resolved (the latter wins if non-null). This is the same for documents and subresources. Tests: web-platform-tests/wpt#27575. HTML change: whatwg/html#6391. Follow-ups: #1167 and #1175. Fixes #505.
1 parent 48b67c7 commit a876e5d

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

fetch.bs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,6 @@ number.
218218
<p class="note no-backref"><a>HTTP(S) scheme</a> and <a>fetch scheme</a> are also used by
219219
<cite>HTML</cite>. [[HTML]]
220220

221-
<hr>
222-
223-
<p id=fetch-url>A <dfn>response URL</dfn> is a <a for=/>URL</a> for which implementations need not
224-
store the <a for=url>fragment</a> as it is never exposed. When
225-
<a lt="URL serializer">serialized</a>, <a for="URL serializer"><i>exclude fragment</i></a> is set to
226-
true, meaning implementations can store the <a for=url>fragment</a> nonetheless.
227-
228221

229222
<h3 id=http>HTTP</h3>
230223

@@ -1840,15 +1833,15 @@ end-user.
18401833

18411834
<p>A <a for=/>response</a> has an associated
18421835
<dfn export for=response id=concept-response-url>URL</dfn>. It is a pointer to the last
1843-
<a>response URL</a> in <a for=/>response</a>'s <a for=response>URL list</a> and null if
1844-
<a for=/>response</a>'s <a for=response>URL list</a> is the empty list.
1836+
<a for=/>URL</a> in <a for=/>response</a>'s <a for=response>URL list</a> and null if
1837+
<a for=/>response</a>'s <a for=response>URL list</a> <a for=list>is empty</a>.
18451838

18461839
<p>A <a for=/>response</a> has an associated
18471840
<dfn export for=response id=concept-response-url-list>URL list</dfn> (a <a for=/>list</a> of zero or
1848-
more <a>response URLs</a>). Unless stated otherwise, it is the empty list.
1841+
more <a for=/>URLs</a>). Unless stated otherwise, it is the empty list.
18491842

1850-
<p class="note no-backref">Except for the last <a>response URL</a>, if any, a
1851-
<a for=/>response</a>'s <a for=response>URL list</a> cannot be exposed to script. That would violate
1843+
<p class="note no-backref">Except for the last <a for=/>URL</a>, if any, a <a for=/>response</a>'s
1844+
<a for=response>URL list</a> is not exposed to script as that would violate
18521845
<a>atomic HTTP redirect handling</a>.
18531846

18541847
<p>A <a for=/>response</a> has an associated
@@ -2028,8 +2021,9 @@ not a <a>fresh response</a> or a <a>stale-while-revalidate response</a>.
20282021

20292022
<hr>
20302023

2031-
<p>The <dfn export for=response id=concept-response-location-url>location URL</dfn> algorithm of
2032-
given a <a for=/>response</a> <var>response</var> is the following steps. They return null, failure,
2024+
<p>The <dfn export for=response id=concept-response-location-url>location URL</dfn> of a
2025+
<a for=/>response</a> <var>response</var>, given null or an <a for=/>ASCII string</a>
2026+
<var>requestFragment</var>, is the value returned by the following steps. They return null, failure,
20332027
or a <a for=/>URL</a>.
20342028

20352029
<ol>
@@ -2049,6 +2043,13 @@ or a <a for=/>URL</a>.
20492043
<var>response</var>'s <a for=response>URL</a> will be null, meaning that <var>location</var> will
20502044
only parse successfully if it is an <a>absolute-URL-with-fragment string</a>.
20512045

2046+
<li>
2047+
<p>If <var>locationURL</var>'s <a for=url>fragment</a> is null, then set <var>locationURL</var>'s
2048+
<a for=url>fragment</a> to <var>requestFragment</var>.
2049+
2050+
<p class=note>This ensures that synthetic (indeed, all) responses follow the processing model for
2051+
redirects defined by HTTP. [[HTTP-SEMANTICS]]
2052+
20522053
<li><p>Return <var>location</var>.
20532054
</ol>
20542055

@@ -3976,7 +3977,8 @@ run these steps:
39763977
<a>filtered response</a>, and <var>response</var>'s
39773978
<a for="filtered response">internal response</a> otherwise.
39783979

3979-
<li><p>Let <var>locationURL</var> be <var>actualResponse</var>'s <a for=response>location URL</a>.
3980+
<li><p>Let <var>locationURL</var> be <var>actualResponse</var>'s <a for=response>location URL</a>
3981+
given <var>request</var>'s <a for=request>current URL</a>'s <a for=url>fragment</a>.
39803982

39813983
<li><p>If <var>locationURL</var> is null, then return <var>response</var>.
39823984

0 commit comments

Comments
 (0)