Skip to content

Commit

Permalink
Re-spec <meta name="referrer"> to match browsers
Browse files Browse the repository at this point in the history
It turns out they only look at the most-recently-inserted-or-mutated <meta> element.

Closes #8525.
  • Loading branch information
domenic committed Dec 8, 2022
1 parent a22deae commit 66bc0c4
Showing 1 changed file with 45 additions and 56 deletions.
101 changes: 45 additions & 56 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -15736,72 +15736,61 @@ interface <dfn interface>HTMLMetaElement</dfn> : <span>HTMLElement</span> {

<div w-nodev>

<p>If any <code>meta</code> elements are <span data-x="node is inserted into a
document">inserted into the document</span> or <span data-x="node is removed from a
document">removed from the document</span>, or existing
<code>meta</code> elements have their <code data-x="attr-meta-name">name</code> or <code
data-x="attr-meta-content">content</code> attributes changed, user agents must run the
following algorithm:</p>
<p>If any <code>meta</code> element <var>element</var> is <span data-x="node is inserted into a
document">inserted into the document</span>, or has its <code
data-x="attr-meta-name">name</code> or <code data-x="attr-meta-content">content</code>
attributes changed, user agents must run the following algorithm:</p>

<ol>
<li>
<p>Let <var>candidate elements</var> be the list of all <code>meta</code> elements that
meet the following criteria, in <span>tree order</span>:</p>
<li><p>If <var>element</var> is not <span>in a document tree</span>, then return.</p></li>

<ul class="brief">
<li>The element is <span>in a document tree</span></li>
<li>The element has a <code data-x="attr-meta-name">name</code> attribute, whose value is
an <span>ASCII case-insensitive</span> match for <code data-x="meta-referrer">referrer</code></li>
<li>The element has a <code data-x="attr-meta-content">content</code> attribute, whose value
is not the empty string</li>
</ul>
</li>
<li><p>If <var>element</var> does not have a <code data-x="attr-meta-name">name</code>
attribute whose value is an <span>ASCII case-insensitive</span> match for "<code
data-x="meta-referrer">referrer</code>", then return.</p></li>

<li>
<p>For each <var>element</var> in <var>candidate elements</var>:</p>
<li><p>If <var>element</var> does not have a <code data-x="attr-meta-content">content</code>
attribute, or that attribute's value is the empty string, then return.</p></li>

<ol>
<li><p>Let <var>value</var> be the value of <var>element</var>'s <code
data-x="attr-meta-content">content</code> attribute, <span>converted to ASCII
lowercase</span>.</p></li>
<li><p>Let <var>value</var> be the value of <var>element</var>'s <code
data-x="attr-meta-content">content</code> attribute, <span>converted to ASCII
lowercase</span>.</p></li>

<li>
<p>If <var>value</var> is one of the values given in the first column of the following
table, then set <var>value</var> to the value given in the second column:</p>

<table>
<thead>
<tr>
<th>Legacy value
<th>Referrer policy
<tbody>
<tr>
<td><code data-x="">never</code>
<td><code data-x="referrer-policy-no-referrer">no-referrer</code>
<tr>
<td><code data-x="">default</code>
<td>the <span>default referrer policy</span>
<tr>
<td><code data-x="">always</code>
<td><code data-x="referrer-policy-unsafe-url">unsafe-url</code>
<tr>
<td><code data-x="">origin-when-crossorigin</code>
<td><code data-x="referrer-policy-origin-when-cross-origin">origin-when-cross-origin</code>
</table>
</li>

<li><p>If <var>value</var> is a <span>referrer policy</span>, then set <var>element</var>'s
<span>node document</span>'s <span data-x="concept-document-policy-container">policy
container</span>'s <span data-x="policy-container-referrer-policy">referrer policy</span> to
<var>policy</var>.</p></li>
</ol>
<li>
<p>If <var>value</var> is one of the values given in the first column of the following table,
then set <var>value</var> to the value given in the second column:</p>

<p class="note">The fact that these steps are applied for each element enables <a
href="https://w3c.github.io/webappsec-referrer-policy/#unknown-policy-values">deployment of
fallback values for older user agents</a>. <ref spec=REFERRERPOLICY></p>
<table>
<thead>
<tr>
<th>Legacy value
<th>Referrer policy
<tbody>
<tr>
<td><code data-x="">never</code>
<td><code data-x="referrer-policy-no-referrer">no-referrer</code>
<tr>
<td><code data-x="">default</code>
<td>the <span>default referrer policy</span>
<tr>
<td><code data-x="">always</code>
<td><code data-x="referrer-policy-unsafe-url">unsafe-url</code>
<tr>
<td><code data-x="">origin-when-crossorigin</code>
<td><code data-x="referrer-policy-origin-when-cross-origin">origin-when-cross-origin</code>
</table>
</li>

<li><p>If <var>value</var> is a <span>referrer policy</span>, then set <var>element</var>'s
<span>node document</span>'s <span data-x="concept-document-policy-container">policy
container</span>'s <span data-x="policy-container-referrer-policy">referrer policy</span> to
<var>policy</var>.</p></li>
</ol>

<p class="note">For historical reasons, unlike other standard metadata names, the processing
model for <code data-x="meta-referrer">referrer</code> is not responsive to element removals,
and does not use <span>tree order</span>. Only the most-recently-inserted or
most-recently-modified <code>meta</code> element in this state has an effect.</p>

</div>
</dd>

Expand Down

0 comments on commit 66bc0c4

Please sign in to comment.