Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct URL parsing of base elements #1064

Merged
merged 2 commits into from
Apr 20, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -12073,9 +12073,10 @@ gave me some of the songs they wrote. I love sharing my music.</p>
data-x="attr-base-target">target</code> attributes, all but the first are ignored.</p>

<p>A <code>base</code> element that is the first <code>base</code> element with an <code
data-x="attr-base-href">href</code> content attribute in a particular <code>Document</code> has a
<dfn>frozen base URL</dfn>. The <span>frozen base URL</span> must be <span>immediately</span> <span data-x="set the frozen
base URL">set</span> for an element whenever any of the following situations occur:</p>
data-x="attr-base-href">href</code> content attribute <span>in a <code>Document</code></span> has
a <dfn>frozen base URL</dfn>. The <span>frozen base URL</span> must be <span>immediately</span>
<span data-x="set the frozen base URL">set</span> for an element whenever any of the following
situations occur:</p>

<ul class="brief">

Expand All @@ -12095,47 +12096,46 @@ gave me some of the songs they wrote. I love sharing my music.&lt;/p>
<ol>
<li><p>Let <var>document</var> be <var>element</var>'s <span>node document</span>.

<li><p><span data-x="parse a URL">Parse</span> the value of <var>element</var>'s <code
data-x="attr-base-href">href</code> content attribute relative to <var>document</var>.</p></li>

<li>
<p>If that algorithm fails or if running <span>Is base allowed for Document?</span> on the
<span>resulting URL record</span> and <var>document</var> returns "<code
data-x="">Blocked</code>", then set <var>element</var>'s <span>frozen base URL</span> to the
<span>fallback base URL</span>.</p>
<li><p>Let <var>urlRecord</var> be the result of <span data-x="URL parser">parsing</span> the
value of <var>element</var>'s <code data-x="attr-base-href">href</code> content attribute with
<var>document</var>'s <span>fallback base URL</span>, and <var>document</var>'s <span
data-x="document's character encoding">character encoding</span>. (Thus, the <code>base</code>
element isn't affected by itself.)</p></li>
<!-- This uses the URL parser rather than parse a URL since otherwise we'd have to unnessarily
complicate the latter for two callsites. -->

<p>Otherwise, set <var>element</var>'s <span>frozen base URL</span> to the <var>resulting URL
record</var>.</p>
</li>
<li><p>Set <var>element</var>'s <span>frozen base URL</span> to <var>document</var>'s
<span>fallback base URL</span>, if <var>urlRecord</var> is failure or running <span>Is base
allowed for Document?</span> on the <span>resulting URL record</span> and <var>document</var>
returns "<code data-x="">Blocked</code>", and to <var>urlRecord</var> otherwise.</p></li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CSP integration LGTM.

</ol>

<p>The <dfn><code data-x="dom-base-href">href</code></dfn> IDL attribute, on getting, must return
the result of running the following algorithm:
<!-- http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1715
https://github.com/whatwg/html/issues/1060#issuecomment-211221664 -->

<ol> <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1715 -->

<li><p>If the <code>base</code> element has no <code data-x="attr-base-href">href</code> content
attribute, then return the <span>document base URL</span> and abort these steps.</p></li>
<ol>
<li><p>If this element has a <span>frozen base URL</span>, return it, <span
data-x="concept-url-serialiser">serialised</span>.</p></li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: "return its serialization" sounds a little better to my ear.


<li><p>Let <var>fallback base url</var> be the <code>Document</code>'s <span>fallback
base URL</span>.</p></li>
<li><p>Let <var>document</var> be <var>element</var>'s <span>node document</span>.

<li><p>Let <var>url</var> be the value of the <code data-x="attr-base-href">href</code>
attribute of the <code>base</code> element.</p></li>
attribute of this element, if it has one, and the empty string otherwise.</p></li>

<li><p>Let <var>urlRecord</var> be the result of <span data-x="URL parser">parsing</span>
<var>url</var> with <var>fallback base url</var>, and the <code>Document</code>'s <span
data-x="document's character encoding">character encoding</span>. (Thus, the <code>base</code>'s
<code data-x="attr-base-href">href</code> attribute isn't affected by other <code>base</code>
elements).</p></li>
<var>url</var> with <var>document</var>'s <span>fallback base URL</span>, and
<var>document</var>'s <span data-x="document's character encoding">character encoding</span>.
(Thus, the <code>base</code> element isn't affected by other <code>base</code> elements or
itself.)</p></li>
<!-- This uses the URL parser rather than parse a URL since otherwise we'd have to unnessarily
complicate the latter for this single callsite. -->
complicate the latter for two callsites. -->

<li><p>If <var>urlRecord</var> is failure, return the empty string.</p></li>

<li><p>Return the <span data-x="concept-url-serialiser">serialisation</span> of
<var>urlRecord</var>.</p></li>

</ol>

<p>The <code data-x="dom-base-href">href</code> IDL attribute, on setting, must set the <code
Expand Down