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

Reject non-IPv4 hostnames that end in numbers. #619

Merged
merged 9 commits into from
Aug 5, 2021
Merged
Changes from 7 commits
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
50 changes: 37 additions & 13 deletions url.bs
Original file line number Diff line number Diff line change
Expand Up @@ -655,17 +655,44 @@ runs these steps:
<li><p>If <var>asciiDomain</var> contains a <a>forbidden host code point</a>,
<a>validation error</a>, return failure.

<li><p>Let <var>ipv4Host</var> be the result of <a lt="IPv4 parser">IPv4 parsing</a>
<var>asciiDomain</var>.

<li><p>If <var>ipv4Host</var> is an <a>IPv4 address</a> or failure, return
<var>ipv4Host</var>.
<li><p>If <var>asciiDomain</var> <a lt="ends in a number checker">ends in a number</a>, return
the result of <a lt="IPv4 parser">IPv4 parsing</a> <var>asciiDomain</var>.

<li><p>Return <var>asciiDomain</var>.
</ol>

<hr>

<p>The <dfn id=ends-in-a-number>ends in a number checker</dfn> takes a string <var>input</var> and
then runs these steps:

<ol>
<li><p>Let <var>parts</var> be the result of <a>strictly splitting</a> <var>input</var> on
U+002E (.).

<li>
<p>If the last <a for=list>item</a> in <var>parts</var> is the empty string, then:

<ol>
<li><p>If <var>parts</var>'s <a for=list>size</a> is 1, return false.
annevk marked this conversation as resolved.
Show resolved Hide resolved

<li><p><a for=list>remove</a> the last <a for=list>item</a> from <var>parts</var>.
annevk marked this conversation as resolved.
Show resolved Hide resolved
</ol>

<li><p>Let <var>last</var> be the last <a for=list>item</a> from <var>parts</var>.
annevk marked this conversation as resolved.
Show resolved Hide resolved

<li><p>If parsing <var>last</var> as an <a lt="IPv4 number parser">IPv4 number</a> does not
return failure, return true.
annevk marked this conversation as resolved.
Show resolved Hide resolved

<li><p>If <var>last</var> is non-empty and contains only <a>ASCII digits</a>, return true.
MattMenke2 marked this conversation as resolved.
Show resolved Hide resolved

<p class="note no-backref">This can happen if <var>last</var> starts with "0" so the
<a lt="IPv4 number parser">IPv4 number parser</a> tries to parse it as octal, but it is not
a valid octal number, as is the case with, for example, "09".

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

<p>The <dfn id=concept-ipv4-parser>IPv4 parser</dfn> takes a string <var>input</var> and then runs
these steps:

Expand All @@ -692,24 +719,19 @@ these steps:
but if it somehow is this conditional makes sure we can keep going. -->
</ol>

<li><p>If <var>parts</var>'s <a for=list>size</a> is greater than 4, then return <var>input</var>.
<li><p>If <var>parts</var>'s <a for=list>size</a> is greater than 4, then <a>validation error</a>,
return failure.

<li><p>Let <var>numbers</var> be an empty <a for=/>list</a>.

<li>
<p><a for=list>For each</a> <var>part</var> of <var>parts</var>:

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

<p class="example no-backref" id=example-c2afe535><code>0..0x300</code> is a
<a>domain</a>, not an <a>IPv4 address</a>.

<li><p>Let <var>result</var> be the result of <a lt="IPv4 number parser">parsing</a>
<var>part</var>.

<li><p>If <var>result</var> is failure, then return <var>input</var>.
<li><p>If <var>result</var> is failure, then <a>validation error</a>, return failure.

<li><p>If <var>result</var>[1] is true, then set <var>validationError</var> to true.

Expand Down Expand Up @@ -754,6 +776,8 @@ these steps:
<p>The <dfn>IPv4 number parser</dfn> takes a string <var>input</var> and then runs these steps:

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

<li><p>Let <var>validationError</var> be false.

<li><p>Let <var>R</var> be 10.
Expand Down