Skip to content

Commit 5c8512d

Browse files
committed
Fix #511: validate external type
Signed-off-by: Zoltan Kis <[email protected]>
1 parent 2740b0b commit 5c8512d

File tree

1 file changed

+53
-23
lines changed

1 file changed

+53
-23
lines changed

index.html

Lines changed: 53 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2742,43 +2742,73 @@ <h3><dfn>Writing or pushing content</dfn></h3>
27422742
</p>
27432743
<ol class=algorithm id="validate-external-type">
27442744
<li>
2745-
If |input:string| is not a {{USVString}} or it is empty, or its
2745+
If |input:string| is not an [=ASCII string=] or it is empty, or its
27462746
length exceeds 255 bytes, return `false`.
27472747
</li>
27482748
<li>
2749-
Let |domain| be the |input| from the start of |input| up to but
2750-
excluding the last occurrence of U+003A (`:`), or `null` if that is
2751-
not found.
2752-
</li>
2753-
<li>
2754-
Let |type| be the |input| after the last occurrence, if any, of
2755-
`U+003A` (`:`) up to the end of |input|, or `null` if that is
2756-
not found.
2757-
</li>
2758-
<li>
2759-
If |domain| or |type| is `null`, return `false`.
2749+
If input starts with `U+005B` (`[`), then:
2750+
<ol>
2751+
<li>
2752+
Let |address| be the part of input between `U+005B` (`[`) and
2753+
the first occurrence of `U+005D` (`]`) or `null` if that is not
2754+
found.
2755+
</li>
2756+
<li>
2757+
If |address| is `null`, return `false`.
2758+
</li>
2759+
<li>
2760+
Let |domain| be the result of running
2761+
<a href="https://url.spec.whatwg.org/#concept-ipv6-parser">
2762+
IPv6 parsing</a> on |address|.
2763+
</li>
2764+
<li>
2765+
If |domain| is failure, return `false`.
2766+
</li>
2767+
<li>
2768+
Let |rest| be the |input| after the first occurrence, if any, of
2769+
`U+005D` (`]`) up to the end of |input|, or `null` if that is
2770+
not found.
2771+
</li>
2772+
<li>
2773+
If |rest| is `null`, or it contains less than 2 [=code points=],
2774+
or the first [=code point=] in |rest| is not `U+003A` (`:`),
2775+
return `false`.
2776+
</li>
2777+
<li>
2778+
Let |type| be |rest| from the second [=code point=] up to the end
2779+
of |rest|.
2780+
</li>
2781+
</ol>
27602782
</li>
27612783
<li>
2762-
Run the following sub-steps of
2763-
<a href="https://url.spec.whatwg.org/#host-parsing">host parsing</a>
2764-
on |domain|:
2765-
<ul>
2784+
Otherwise,
2785+
<ol>
2786+
<li>
2787+
Let |domain| be the |input| from the start of |input| up to
2788+
but excluding the first occurrence of `U+003A` (`:`), or `null`
2789+
if that is not found.
2790+
</li>
2791+
<li>
2792+
Let |type| be the |input| after the first occurrence, if any, of
2793+
`U+003A` (`:`) up to the end of |input|, or `null` if that is
2794+
not found.
2795+
</li>
2796+
<li>
2797+
If |domain| or |type| is `null`, return `false`.
2798+
</li>
27662799
<li>
27672800
Let |asciiDomain| be the result of running
27682801
<a href="https://url.spec.whatwg.org/#concept-domain-to-ascii">
2769-
domain to ASCII</a> on |domain|.
2802+
domain to ASCII</a> given |domain| and `true` (as |beStrict|).
27702803
</li>
27712804
<li>
27722805
If |asciiDomain| is failure, return `false`.
27732806
</li>
27742807
<li>
2775-
If |asciiDomain| contains a [=forbidden host code point=],
2776-
return `false`.
2808+
If |asciiDomain| contains a [=forbidden host code point=] or
2809+
`U+005F` `LOW LINE` (`_`), return `false`.
27772810
</li>
2778-
</ul>
2779-
</li>
2780-
<li>
2781-
If |type| is empty, return `false`.
2811+
</ol>
27822812
</li>
27832813
<li>
27842814
If |type| contains [=code points=] that are not

0 commit comments

Comments
 (0)