Skip to content

Commit

Permalink
Add dangling markup mitigation to the spec
Browse files Browse the repository at this point in the history
  • Loading branch information
shhnjk committed Dec 26, 2023
1 parent 9e72bf9 commit 1324148
Showing 1 changed file with 31 additions and 16 deletions.
47 changes: 31 additions & 16 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -7079,21 +7079,36 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
several wrappers to abstract base URLs and encodings. <ref>URL</ref></p>

<p class="note">Most new APIs are to use <span>parse a URL</span>. Older APIs and HTML elements
might have reason to use <span data-x="encoding-parsing a URL">encoding-parse a URL</span>. When a
custom base URL is needed or no base URL is desired, the <span>URL parser</span> can of course be
used directly as well.</p>
might have reason to use <span data-x="encoding-parsing a URL">encoding-parse a URL</span>. If a
URL parsing was invoked as a result of HTML parsing (i.e. not from an API call), then
<span>parse a URL</span> should be used instead of calling <span>URL parser</span> directly.</p>

<p>To <dfn export>parse a URL</dfn>, given a string <var>url</var>, relative to a
<code>Document</code> object or <span>environment settings object</span> <var>environment</var>,
run these steps. They return failure or a <span>URL</span>.</p>
<p>To <dfn export>parse a URL</dfn>, given a <span>scalar value string</span> <var>url</var>,
relative to a <code>Document</code> object or <span>environment settings object</span>
<var>environment</var>,and an optional <span>encoding</span> <var>encoding</var> (default
<span>UTF-8</span>), run these steps. They return failure or a <span>URL</span>.</p>

<ol>
<li><p>Let <var>baseURL</var> be <var>environment</var>'s <span data-x="document base URL">base
URL</span>, if <var>environment</var> is a <code>Document</code> object; otherwise
<var>environment</var>'s <span>API base URL</span>.</p></li>

<li><p>Let <var>newline</var> and <var>lt</var> flag be false.</p></li>

<li><p>For each <var>byte</var> in <var>url</var>:</p>
<ol>
<li><p>If <var>byte</var> is an <span>ASCII tab or newline</span> character, then set the
<var>newline</var> flag to true.</p></li>

<li><p>Otherwise, if <var>byte</var> is a U+003C (&lt;) character, set the <var>lt</var> flag
to true.</p></li>
</ol>
</li>

<li><p>If both <var>newline</var> and <var>lt</var> flags are true, then return failure.</p></li>

<li><p>Return the result of applying the <span>URL parser</span> to <var>url</var>, with
<var>baseURL</var>.</p></li>
<var>baseURL</var> and <var>encoding</var>.</p></li>
</ol>

<p id="resolve-a-url">To <dfn export data-x="encoding-parsing a URL">encoding-parse a URL</dfn>,
Expand All @@ -7114,12 +7129,12 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<code>Document</code></span>'s <span data-x="document's character encoding">character
encoding</span>.</p></li>

<li><p>Let <var>baseURL</var> be <var>environment</var>'s <span data-x="document base URL">base
URL</span>, if <var>environment</var> is a <code>Document</code> object; otherwise
<var>environment</var>'s <span>API base URL</span>.</p></li>
<li><p>If <var>environment</var> is a <code>Document</code> object, then return the result of
<span data-x="parse a URL">parsing a URL</span> with <var>url</var> and <var>encoding</var>.</p>
</li>

<li><p>Return the result of applying the <span>URL parser</span> to <var>url</var>, with
<var>baseURL</var> and <var>encoding</var>.</p></li>
<li>Otherwise, return the result of applying the <span>URL parser</span> to <var>url</var>, with
<var>environment</var>'s <span>API base URL</span> and <var>encoding</var>.</p></li>
</ol>

<p>To <dfn data-x="encoding-parsing-and-serializing a URL">encoding-parse-and-serialize a
Expand Down Expand Up @@ -14962,7 +14977,7 @@ interface <dfn interface>HTMLBaseElement</dfn> : <span>HTMLElement</span> {
<ol>
<li><p>Let <var>document</var> be <var>element</var>'s <span>node document</span>.

<li><p>Let <var>urlRecord</var> be the result of <span data-x="URL parser">parsing</span> the
<li><p>Let <var>urlRecord</var> be the result of <span data-x="parse a URL">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>
Expand Down Expand Up @@ -34351,7 +34366,7 @@ interface <dfn interface>HTMLObjectElement</dfn> : <span>HTMLElement</span> {
<!-- if we get to this point we know we can successfully parsed the URL, since this
algorithm is only used after fetching the resource in the steps above -->

<p>If applying the <span>URL parser</span> algorithm to the <span>URL</span> of the
<p>If applying the <span>parse a URL</span> algorithm to the <span>URL</span> of the
specified resource (after any redirects) results in a <span>URL record</span> whose <span
data-x="concept-url-path">path</span> component matches a pattern that a <span>plugin</span>
supports, then let <var>resource type</var> be the type that that plugin can
Expand Down Expand Up @@ -103841,7 +103856,7 @@ new PaymentRequest(&hellip;); // Allowed to use

<dd>
<p>A <span>URL</span> used by APIs called by scripts that use this <span>environment settings
object</span> to <span data-x="parse a URL">parse URLs</span>.</p>
object</span> to <span data-x="URL parser">parse URLs</span>.</p>
</dd>

<dt>An <dfn data-x="concept-settings-object-origin" export for="environment
Expand Down Expand Up @@ -112360,7 +112375,7 @@ interface <dfn interface>Navigator</dfn> {
<li><p>Replace the first instance of "<code data-x="">%s</code>" in <var>handlerURLString</var>
with <var>encodedURL</var>.</p></li>

<li><p>Let <var>resultURL</var> be the result of <span data-x="URL parser">parsing</span>
<li><p>Let <var>resultURL</var> be the result of <span data-x="parse a URL">parsing</span>
<var>handlerURLString</var>.</p></li>

<li><p><span>Navigate</span><!--DONAV user--> an appropriate <span>navigable</span> to
Expand Down

0 comments on commit 1324148

Please sign in to comment.