Skip to content
Permalink
Browse files

Ensure Refresh pragma always uses a URL record

Before this change you could sometimes end up passing a string to navigate. This also reduces the number of jumps, adds a flag we can reuse for the eventual definition of the HTTP Refresh header, and confines the remaining jumps to a single block.
  • Loading branch information...
annevk committed Aug 2, 2017
1 parent 5dc7db2 commit 64ea79523e6565070c9f5af7397a8104d7841cf9
Showing with 62 additions and 65 deletions.
  1. +62 −65 source
127 source

<p>This pragma acts as timed redirect.</p>

<p>A <code>Document</code> object has an associated <dfn data-dfn-for="Document">will
declaratively refresh</dfn> (a boolean). It is initially false.</p>

<div w-nodev>

<ol>
<!-- TESTS: https://www.hixie.ch/tests/adhoc/html/meta/refresh/ -->
<!-- https://software.hixie.ch/utilities/js/live-dom-viewer/?saved=734 -->
<li><p>Let <var>document</var> be the <code>meta</code> element's <span>node
document</span>.</p></li>

<li><p>If another <code>meta</code> element with an <code
data-x="attr-meta-http-equiv">http-equiv</code> attribute in the <span
data-x="attr-meta-http-equiv-refresh">Refresh state</span> has already been successfully
processed (i.e. when it was inserted the user agent processed it and reached the step labeled
<i>end</i>), then return.</p></li>
<li><p>If <var>document</var>'s <span>will declaratively refresh</span> is true, then
return.</p></li>

<li><p>If the <code>meta</code> element has no <code data-x="attr-meta-content">content</code>
attribute, or if that attribute's value is the empty string, then return.</p></li>

<li><p>Let <var>document</var> be the <code>meta</code> element's <span>node
document</span>.</p></li>

<li><p>Let <var>input</var> be the value of the element's <code
data-x="attr-meta-content">content</code> attribute.</p></li>

U+002E FULL STOP characters (.) from <var>input</var> given <var>position</var>. Ignore any
collected characters.</p></li>

<li><p>Let <var>url</var> be <var>document</var>'s <span
data-x="concept-document-URL">URL</span>, <span
data-x="concept-url-serializer">serialized</span>.</p></li>
<li><p>Let <var>urlRecord</var> be <var>document</var>'s <span
data-x="concept-document-URL">URL</span>.</p></li>

<li><p>If <var>position</var> is past the end of <var>input</var>, jump to the step labeled
<i>end</i>.</p></li>
<li>
<p>If <var>position</var> is not past the end of <var>input</var>, then:</p>

<li><p>If the <span>code point</span> in <var>input</var> pointed to by <var>position</var> is
not U+003B (;), U+002C (,), or <span>ASCII whitespace</span>, then return.</p></li>
<ol>
<li><p>If the <span>code point</span> in <var>input</var> pointed to by <var>position</var>
is not U+003B (;), U+002C (,), or <span>ASCII whitespace</span>, then return.</p></li>

<li><p><span>Skip ASCII whitespace</span> within <var>input</var> given
<var>position</var>.</p></li>
<li><p><span>Skip ASCII whitespace</span> within <var>input</var> given
<var>position</var>.</p></li>

<li><p>If the <span>code point</span> in <var>input</var> pointed to by <var>position</var> is
U+003B (;) or U+002C (,), then advance <var>position</var> to the next <span>code
point</span>.</p></li>
<li><p>If the <span>code point</span> in <var>input</var> pointed to by <var>position</var>
is U+003B (;) or U+002C (,), then advance <var>position</var> to the next <span>code
point</span>.</p></li>

<li><p><span>Skip ASCII whitespace</span> within <var>input</var> given
<var>position</var>.</p></li>
<li><p><span>Skip ASCII whitespace</span> within <var>input</var> given
<var>position</var>.</p></li>
</ol>
</li>

<li><p>If <var>position</var> is past the end of <var>input</var>, jump to the step labeled
<i>end</i>.</p></li>
<li>
<p>If <var>position</var> is not past the end of <var>input</var>, then:</p>

<ol>
<li><p>Let <var>urlString</var> be the substring of <var>input</var> from the
<span>code point</span> at <var>position</var> to the end of the string.</p></li>

<li><p>Set <var>url</var> to the substring of <var>input</var> from the <span>code point</span>
at <var>position</var> to the end of the string.</p></li>
<li><p>If the <span>code point</span> in <var>input</var> pointed to by <var>position</var>
is U+0055 (U) or U+0075 (u), then advance <var>position</var> to the next <span>code
point</span>. Otherwise, jump to the step labeled <i>skip quotes</i>.</p></li>

<li><p>If the <span>code point</span> in <var>input</var> pointed to by <var>position</var> is
U+0055 (U) or U+0075 (u), then advance <var>position</var> to the next <span>code point</span>.
Otherwise, jump to the step labeled <i>skip quotes</i>.</p></li>
<li><p>If the <span>code point</span> in <var>input</var> pointed to by <var>position</var>
is U+0052 (R) or U+0072 (r), then advance <var>position</var> to the next <span>code
point</span>. Otherwise, jump to the step labeled <i>parse</i>.</p></li>

<li><p>If the <span>code point</span> in <var>input</var> pointed to by <var>position</var> is
U+0052 (R) or U+0072 (r), then advance <var>position</var> to the next <span>code point</span>.
Otherwise, jump to the step labeled <i>parse</i>.</p></li>
<li><p>If the <span>code point</span> in <var>input</var> pointed to by <var>position</var>
is U+004C (L) or U+006C (l), then advance <var>position</var> to the next <span>code
point</span>. Otherwise, jump to the step labeled <i>parse</i>.</p></li>

<li><p>If the <span>code point</span> in <var>input</var> pointed to by <var>position</var> is
U+004C (L) or U+006C (l), then advance <var>position</var> to the next <span>code point</span>.
Otherwise, jump to the step labeled <i>parse</i>.</p></li>
<li><p><span>Skip ASCII whitespace</span> within <var>input</var> given
<var>position</var>.</p></li>

<li><p><span>Skip ASCII whitespace</span> within <var>input</var> given
<var>position</var>.</p></li>
<li><p>If the <span>code point</span> in <var>input</var> pointed to by <var>position</var>
is U+003D (=), then advance <var>position</var> to the next <span>code point</span>.
Otherwise, jump to the step labeled <i>parse</i>.</p></li>

<li><p>If the <span>code point</span> in <var>input</var> pointed to by <var>position</var> is
U+003D (=), then advance <var>position</var> to the next <span>code point</span>. Otherwise,
jump to the step labeled <i>parse</i>.</p></li>
<li><p><span>Skip ASCII whitespace</span> within <var>input</var> given
<var>position</var>.</p></li>

<li><p><span>Skip ASCII whitespace</span> within <var>input</var> given
<var>position</var>.</p></li>
<li><p><i>Skip quotes</i>: If the <span>code point</span> in <var>input</var> pointed to by
<var>position</var> is U+0027 (') or U+0022 ("), then let <var>quote</var> be that <span>code
point</span>, and advance <var>position</var> to the next <span>code point</span>. Otherwise,
let <var>quote</var> be the empty string.</p></li>

<li><p><i>Skip quotes</i>: If the <span>code point</span> in <var>input</var> pointed to by
<var>position</var> is U+0027 (') or U+0022 ("), then let <var>quote</var> be that <span>code
point</span>, and advance <var>position</var> to the next <span>code point</span>. Otherwise,
let <var>quote</var> be the empty string.</p></li>
<li><p>Set <var>urlString</var> to the substring of <var>input</var> from the <span>code
point</span> at <var>position</var> to the end of the string.</p></li>

<li><p>Set <var>url</var> to the substring of <var>input</var> from the <span>code point</span>
at <var>position</var> to the end of the string.</p></li>
<li><p>If <var>quote</var> is not the empty string, and there is a <span>code point</span> in
<var>urlString</var> equal to <var>quote</var>, then truncate <var>urlString</var> at that
<span>code point</span>, so that it and all subsequent <span data-x="code point">code
points</span> are removed.</p>

<li><p>If <var>quote</var> is not the empty string, and there is a <span>code point</span> in
<var>url</var> equal to <var>quote</var>, then truncate <var>url</var> at that <span>code
point</span>, so that it and all subsequent <span data-x="code point">code points</span> are
removed.</p>
<li><p><i>Parse</i>: <span data-x="parse a url">Parse</span> <var>urlString</var> relative to
<var>document</var>. If that fails, return. Otherwise, set <var>urlRecord</var> to the
<span>resulting URL record</span>.</p></li>
</ol>
</li>

<li><p><i>Parse</i>: <span data-x="parse a url">Parse</span> <var>url</var> relative to
<var>document</var>. If that fails, return. Otherwise, let <var>urlRecord</var> be the
<span>resulting URL record</span>.</p></li>
<li><p>Set <var>document</var>'s <span>will declaratively refresh</span> to true.</p></li>

<li>

<p><i>End</i>: Perform one or more of the following steps:</p>
<p>Perform one or more of the following steps:</p>

<ul>

<li>

<p>After the refresh has come due (as defined below), if the user has not canceled the
redirect and <var>document</var>'s <span>active sandboxing flag set</span> does not have the
<span>sandboxed automatic features browsing context flag</span> set, <span
the <em>later</em> of the following two conditions occurs:</p>

<ul>

<li>At least <var>time</var> seconds have elapsed since <var>document</var> has
<span>completely loaded</span>, adjusted to take into account user or user agent
preferences.</li>
<span data-x="node is inserted into a document">inserted into the document</span>
<var>document</var>, adjusted to take into account user or user agent preferences.</li>
<!-- https://software.hixie.ch/utilities/js/live-dom-viewer/?saved=772 -->

</ul>

<p class="note">It is important to use <var>document</var> here, and not the
<code>meta</code> element's <span>node document</span>, as that might have changed between
the initial set of steps and the refresh coming due.</p>

</li>

<li><p>Provide the user with an interface that, when selected, <span
context</span>.</p></li>

<li><p>Do nothing.</p></li>

</ul>

<p>In addition, the user agent may, as with anything, inform the user of any and all aspects
of its operation, including the state of any timers, the destinations of any timed redirects,
and so forth.</p>

</li>

</ol>

</div>

0 comments on commit 64ea795

Please sign in to comment.
You can’t perform that action at this time.