Skip to content

Commit 6f223de

Browse files
authored
Treat data URLs as same-origin
By-and-large browsers treat data URLs as same-origin, though there are some inconsistencies. This change will treat all data URLs, regardless of origin, as same-origin from the perspective of Fetch. HTML already assigns a unique opague origin to documents created from a data URL and the plan of record is to do so for dedicated workers too. HTML will likely also forbid shared workers to be created from data URLs. See whatwg/html#1782 for the proposed changes to HTML. (This has not landed yet, if that PR is tweaked further the note added here might need some tweaks.) Service workers already prevent anything but HTTP(S) URLs from creating them. Fixes #381.
1 parent 72fc2e7 commit 6f223de

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

Overview.html

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<p><a class="logo" href="https://whatwg.org/"><img alt="WHATWG" height="100" src="https://resources.whatwg.org/logo-fetch.svg" width="100"></a>
99
<h1 id="cors">Fetch</h1>
10-
<h2 class="no-num no-toc" id="living-standard-—-last-updated-14-september-2016">Living Standard — Last Updated 14 September 2016</h2>
10+
<h2 class="no-num no-toc" id="living-standard-—-last-updated-15-september-2016">Living Standard — Last Updated 15 September 2016</h2>
1111

1212
<dl>
1313
<dt>Participate:
@@ -951,10 +951,6 @@ <h4 id="requests"><span class="secno">3.1.5 </span>Requests</h4>
951951
<dfn data-dfn-for="request" data-export="" id="omit-origin-header-flag">omit-<code>Origin</code>-header flag</dfn>. Unless stated
952952
otherwise it is unset.
953953

954-
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
955-
<dfn data-dfn-for="request" data-export="" id="same-origin-data-url-flag">same-origin data-URL flag</dfn>. Unless stated otherwise it is
956-
unset.
957-
958954
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
959955
<dfn data-dfn-for="request" data-export="" id="concept-request-referrer" title="concept-request-referrer">referrer</dfn>, which is
960956
"<code>no-referrer</code>", "<code>client</code>", or a
@@ -2484,9 +2480,7 @@ <h3 id="main-fetch"><span class="secno">5.1 </span>Main fetch</h3>
24842480
<a href="#concept-request-origin" title="concept-request-origin">origin</a> and <i>CORS flag</i> is unset
24852481
<dt><var>request</var>'s
24862482
<a href="#concept-request-current-url" title="concept-request-current-url">current url</a>'s
2487-
<a class="external" data-anolis-spec="url" href="https://url.spec.whatwg.org/#concept-url-scheme" title="concept-url-scheme">scheme</a> is
2488-
"<code title="">data</code>" and <var>request</var>'s
2489-
<a href="#same-origin-data-url-flag">same-origin data-URL flag</a> is set
2483+
<a class="external" data-anolis-spec="url" href="https://url.spec.whatwg.org/#concept-url-scheme" title="concept-url-scheme">scheme</a> is "<code>data</code>"
24902484
<dt><var>request</var>'s <a href="#concept-request-mode" title="concept-request-mode">mode</a> is
24912485
"<code title="">navigate</code>" or "<code title="">websocket</code>"
24922486

@@ -2499,6 +2493,16 @@ <h3 id="main-fetch"><span class="secno">5.1 </span>Main fetch</h3>
24992493
using <var>request</var>.
25002494
</ol>
25012495

2496+
<p class="note no-backref">HTML assigns any documents and dedicated workers created from
2497+
<a class="external" data-anolis-spec="url" href="https://url.spec.whatwg.org/#concept-url" title="concept-url">URLs</a> whose
2498+
<a class="external" data-anolis-spec="url" href="https://url.spec.whatwg.org/#concept-url-scheme" title="concept-url-scheme">scheme</a> is "<code>data</code>" a
2499+
unique <a class="external" data-anolis-spec="html" href="https://html.spec.whatwg.org/multipage/browsers.html#concept-origin-opaque">opaque origin</a>, and prevents creation of shared workers
2500+
from such <a class="external" data-anolis-spec="url" href="https://url.spec.whatwg.org/#concept-url" title="concept-url">URLs</a>. Service workers can only be
2501+
created from <a class="external" data-anolis-spec="url" href="https://url.spec.whatwg.org/#concept-url" title="concept-url">URLs</a> whose
2502+
<a class="external" data-anolis-spec="url" href="https://url.spec.whatwg.org/#concept-url-scheme" title="concept-url-scheme">scheme</a> is an
2503+
<a class="external" data-anolis-spec="url" href="https://url.spec.whatwg.org/#http-scheme">HTTP(S) scheme</a>.
2504+
<a href="#refsHTML">[HTML]</a> <a href="#refsSW">[SW]</a>
2505+
25022506
<dt><var>request</var>'s <a href="#concept-request-mode" title="concept-request-mode">mode</a> is
25032507
"<code title="">same-origin</code>"
25042508

@@ -3059,8 +3063,6 @@ <h3 id="http-redirect-fetch"><span class="secno">5.4 </span>HTTP-redirect fetch<
30593063
<li><p>Increase <var>request</var>'s
30603064
<a href="#concept-request-redirect-count" title="concept-request-redirect-count">redirect count</a> by one.
30613065

3062-
<li><p>Unset <var title="">request</var>'s <a href="#same-origin-data-url-flag">same-origin data-URL flag</a>.
3063-
30643066
<li><p>If <var>request</var>'s <a href="#concept-request-mode" title="concept-request-mode">mode</a> is "<code>cors</code>",
30653067
<var>request</var>'s <a href="#concept-request-origin" title="concept-request-origin">origin</a> is <em>not</em>
30663068
<a class="external" data-anolis-spec="html" href="https://html.spec.whatwg.org/multipage/browsers.html#same-origin">same origin</a> with <var>actualResponse</var>'s
@@ -4683,7 +4685,6 @@ <h3 id="request-class"><span class="secno">6.3 </span>Request class</h3>
46834685
<a href="#concept-request-origin" title="concept-request-origin">origin</a> is "<code>client</code>",
46844686
<a href="#omit-origin-header-flag">omit-<code>Origin</code>-header flag</a> is <var>request</var>'s
46854687
<a href="#omit-origin-header-flag">omit-<code>Origin</code>-header flag</a>,
4686-
<a href="#same-origin-data-url-flag">same-origin data-URL flag</a> is set,
46874688
<a href="#concept-request-referrer" title="concept-request-referrer">referrer</a> is <var>request</var>'s
46884689
<a href="#concept-request-referrer" title="concept-request-referrer">referrer</a>,
46894690
<a href="#concept-request-referrer-policy" title="concept-request-referrer-policy">referrer policy</a> is

Overview.src.html

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -881,10 +881,6 @@ <h4>Requests</h4>
881881
<dfn data-export data-dfn-for=request>omit-<code>Origin</code>-header flag</dfn>. Unless stated
882882
otherwise it is unset.
883883

884-
<p>A <span title=concept-request>request</span> has an associated
885-
<dfn data-export data-dfn-for=request>same-origin data-URL flag</dfn>. Unless stated otherwise it is
886-
unset.
887-
888884
<p>A <span title=concept-request>request</span> has an associated
889885
<dfn title=concept-request-referrer data-export data-dfn-for=request>referrer</dfn>, which is
890886
"<code>no-referrer</code>", "<code>client</code>", or a
@@ -2414,9 +2410,7 @@ <h3>Main fetch</h3>
24142410
<span title=concept-request-origin>origin</span> and <i>CORS flag</i> is unset
24152411
<dt><var>request</var>'s
24162412
<span title=concept-request-current-url>current url</span>'s
2417-
<span data-anolis-spec=url title=concept-url-scheme>scheme</span> is
2418-
"<code title>data</code>" and <var>request</var>'s
2419-
<span>same-origin data-URL flag</span> is set
2413+
<span data-anolis-spec=url title=concept-url-scheme>scheme</span> is "<code>data</code>"
24202414
<dt><var>request</var>'s <span title=concept-request-mode>mode</span> is
24212415
"<code title>navigate</code>" or "<code title>websocket</code>"
24222416

@@ -2429,6 +2423,16 @@ <h3>Main fetch</h3>
24292423
using <var>request</var>.
24302424
</ol>
24312425

2426+
<p class="note no-backref">HTML assigns any documents and dedicated workers created from
2427+
<span data-anolis-spec=url title=concept-url>URLs</span> whose
2428+
<span data-anolis-spec=url title=concept-url-scheme>scheme</span> is "<code>data</code>" a
2429+
unique <span data-anolis-spec=html>opaque origin</span>, and prevents creation of shared workers
2430+
from such <span data-anolis-spec=url title=concept-url>URLs</span>. Service workers can only be
2431+
created from <span data-anolis-spec=url title=concept-url>URLs</span> whose
2432+
<span data-anolis-spec=url title=concept-url-scheme>scheme</span> is an
2433+
<span data-anolis-spec=url>HTTP(S) scheme</span>.
2434+
<span data-anolis-ref>HTML</span> <span data-anolis-ref>SW</span>
2435+
24322436
<dt><var>request</var>'s <span title=concept-request-mode>mode</span> is
24332437
"<code title>same-origin</code>"
24342438

@@ -2989,8 +2993,6 @@ <h3>HTTP-redirect fetch</h3>
29892993
<li><p>Increase <var>request</var>'s
29902994
<span title=concept-request-redirect-count>redirect count</span> by one.
29912995

2992-
<li><p>Unset <var title>request</var>'s <span>same-origin data-URL flag</span>.
2993-
29942996
<li><p>If <var>request</var>'s <span title=concept-request-mode>mode</span> is "<code>cors</code>",
29952997
<var>request</var>'s <span title=concept-request-origin>origin</span> is <em>not</em>
29962998
<span data-anolis-spec=html>same origin</span> with <var>actualResponse</var>'s
@@ -4613,7 +4615,6 @@ <h3>Request class</h3>
46134615
<span title=concept-request-origin>origin</span> is "<code>client</code>",
46144616
<span>omit-<code>Origin</code>-header flag</span> is <var>request</var>'s
46154617
<span>omit-<code>Origin</code>-header flag</span>,
4616-
<span>same-origin data-URL flag</span> is set,
46174618
<span title=concept-request-referrer>referrer</span> is <var>request</var>'s
46184619
<span title=concept-request-referrer>referrer</span>,
46194620
<span title=concept-request-referrer-policy>referrer policy</span> is

0 commit comments

Comments
 (0)