Skip to content

Commit

Permalink
Define document.domain in terms of a reusable algorithm
Browse files Browse the repository at this point in the history
This commit introduces a new primitive that enables document.domain, HTTP cookies, and Web Authentication to share their interaction with the Public Suffix List.

No tests have been written since this is a only exposing a new hook and refactoring existing text in the process.
  • Loading branch information
jcjones authored and annevk committed Feb 22, 2017
1 parent c422734 commit 03bbc6e
Showing 1 changed file with 55 additions and 43 deletions.
98 changes: 55 additions & 43 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -79175,7 +79175,7 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span

<ol>
<li><p>If <var>origin</var> is an <span data-x="concept-origin-opaque">opaque origin</span>, then
return <var>origin</var>.</p></li>
return null.</p></li>

<li><p>If <var>origin</var>'s <span data-x="concept-origin-domain">domain</span> is non-null,
then return <var>origin</var>'s <span data-x="concept-origin-domain">domain</span>.</p></li>
Expand Down Expand Up @@ -79481,6 +79481,49 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span

<div w-nodev>

<p>To determine if a string <var>hostSuffixString</var> <dfn data-export="" data-lt="is a
registrable domain suffix of or is equal to|is not a registrable domain suffix of and is not equal
to">is a registrable domain suffix of or is equal to</dfn> a <span
data-x="concept-host">host</span> <var>originalHost</var>, run these steps:</p>
<!-- Web platform usage: document.domain, Cookies, Web Authentication -->

<ol>
<li><p>If <var>hostSuffixString</var> is the empty string, then return false.</p></li>

<li><p>Let <var>host</var> be the result of <span data-x="host parser">parsing</span>
<var>hostSuffixString</var>.</p></li>

<li><p>If <var>host</var> is failure, then return false.</p></li>

<li>
<p>If <var>host</var> is <em>not</em> <span data-x="host equals">equal</span> to
<var>originalHost</var>, then run these substeps:</p>

<ol>
<li>
<p>If <var>host</var> or <var>originalHost</var> is not a <span
data-x="concept-domain">domain</span>, then return false.</p>

<p class="note">This is meant to exclude <span data-x="concept-host">hosts</span> that are an
<span>IPv4 address</span> or an <span>IPv6 address</span>.</p>
</li>

<li><p>If <var>host</var>, prefixed by a U+002E FULL STOP (.), does not exactly match the end
of <var>originalHost</var>, then return false.</p></li>

<li>
<p>If <var>host</var> matches a suffix in the Public Suffix List, or, if <var>host</var>,
prefixed by a U+002E FULL STOP (.), matches the end of a suffix in the Public Suffix List,
then return false. <ref spec=PSL></p>

<p>Suffixes must be compared after applying the <span>host parser</span> algorithm.</p>
</li>
</ol>
</li>

<li><p>Return true.</p></li>
</ol>

<p>The <dfn><code data-x="dom-document-domain">domain</code></dfn> attribute's getter must run
these steps:</p>

Expand All @@ -79491,8 +79534,7 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span
<li><p>Let <var>effectiveDomain</var> be this <code>Document</code>'s <span>origin</span>'s <span
data-x="concept-origin-effective-domain">effective domain</span>.

<li><p>If <var>effectiveDomain</var> is an <span data-x="concept-origin-opaque">opaque
origin</span>, then return the empty string.</p></li>
<li><p>If <var>effectiveDomain</var> is null, then return the empty string.</p></li>

<li><p>Return <var>effectiveDomain</var>, <span data-x="host
serializer">serialized</span>.</p></li>
Expand All @@ -79511,50 +79553,19 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span
flag</span> set, then throw a <span>"<code>SecurityError</code>"</span>
<code>DOMException</code>.</p></li>

<li><p>If the given value is the empty string, then throw a
<span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>Let <var>host</var> be the result of <span data-x="host parser">parsing</span> the given
value.</p></li>

<li><p>If <var>host</var> is failure, then throw a <span>"<code>SecurityError</code>"</span>
<code>DOMException</code>.</p></li>

<li><p>Let <var>effectiveDomain</var> be this <code>Document</code> object's
<span>origin</span>'s <span data-x="concept-origin-effective-domain">effective
domain</span>.</p></li>

<li>
<p>If <var>host</var> is <em>not</em> <span data-x="host equals">equal</span> to
<var>effectiveDomain</var>, then run these substeps:</p>

<ol>
<li>
<p>If <var>host</var> or <var>effectiveDomain</var> is not a <span
data-x="concept-domain">domain</span>, then throw a <span>"<code>SecurityError</code>"</span>
<code>DOMException</code>.</p>

<p class="note">This is meant to exclude <span data-x="concept-host">hosts</span> that are an
<span>IPv4 address</span> or an <span>IPv6 address</span>.</p>
</li>

<li><p>If <var>host</var>, prefixed by a U+002E FULL STOP (.), does not exactly match the end
of <var>effectiveDomain</var>, then throw a <span>"<code>SecurityError</code>"</span>
<code>DOMException</code>.</p></li>
<li><p>Let <var>effectiveDomain</var> be this <code>Document</code>'s <span>origin</span>'s <span
data-x="concept-origin-effective-domain">effective domain</span>.

<li>
<p>If <var>host</var> matches a suffix in the Public Suffix List, or, if <var>host</var>,
prefixed by a U+002E FULL STOP (.), matches the end of a suffix in the Public Suffix List,
then throw a <span>"<code>SecurityError</code>"</span> <code>DOMException</code>. <ref
spec=PSL></p>
<li><p>If <var>effectiveDomain</var> is null, then throw a
<span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>

<p>Suffixes must be compared after applying the <span>host parser</span> algorithm.</p>
</li>
</ol>
</li>
<li><p>If the given value <span data-x="is a registrable domain suffix of or is equal to">is not
a registrable domain suffix of and is not equal to</span> <var>effectiveDomain</var>, then throw
a <span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>Set this <code>Document</code> object's <span>origin</span>'s <span
data-x="concept-origin-domain">domain</span> to <var>host</var>.</p></li>
data-x="concept-origin-domain">domain</span> to the result of <span data-x="host
parser">parsing</span> the given value.</p></li>
</ol>

</div>
Expand Down Expand Up @@ -119625,6 +119636,7 @@ INSERT INTERFACES HERE
Ivan Enderlin,
Ivo Emanuel Gon&ccedil;alves,
J. King,
J.C. Jones,
Jackson Ray Hamilton,
Jacob Davies,
Jacques Distler,
Expand Down

0 comments on commit 03bbc6e

Please sign in to comment.