Skip to content

Commit b4d672b

Browse files
committed
Make nested comments a parse error
Nesting comments like <!--<!---->--> is an authoring mistake since the comment will end on the first -->. Now that -- in comments is allowed, we need new states to make "<!--" in a comment a parse error.
1 parent 2568463 commit b4d672b

File tree

1 file changed

+69
-9
lines changed

1 file changed

+69
-9
lines changed

source

Lines changed: 69 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98254,14 +98254,21 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
9825498254

9825598255
<h4>Comments</h4>
9825698256

98257-
<p><dfn data-x="syntax-comments">Comments</dfn> must start with the four character sequence U+003C
98258-
LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS (<code
98259-
data-x="">&lt;!--</code>). Following this sequence, the comment may have <span
98260-
data-x="syntax-text">text</span>, with the additional restriction that the text must not start
98261-
with a single U+003E GREATER-THAN SIGN character (&gt;), nor start with a U+002D HYPHEN-MINUS
98262-
character (-) followed by a U+003E GREATER-THAN SIGN (&gt;) character. Finally, the comment must
98263-
be ended by the three character sequence U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E
98264-
GREATER-THAN SIGN (<code data-x="">--&gt;</code>).</p>
98257+
<p><dfn data-x="syntax-comments">Comments</dfn> must have the following format:</p>
98258+
98259+
<ol>
98260+
98261+
<li>The string "<code data-x="">&lt;!--</code>".</li>
98262+
98263+
<li>Optionally, <span data-x="syntax-text">text</span>, with the additional restriction that the
98264+
text must not start with the string "<code data-x="">&gt;</code>", nor start with the string
98265+
"<code data-x="">-></code>", nor contain the string "<code data-x="">&lt;!--</code>", nor end
98266+
with the string "<code data-x="">&lt;!</code>", nor end with the string "<code
98267+
data-x="">&lt;!-</code>".</li>
98268+
98269+
<li>The string "<code data-x="">--&gt;</code>".</li>
98270+
98271+
</ol>
9826598272

9826698273

9826798274
<!--HTMLPARSER-->
@@ -101198,8 +101205,12 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
101198101205

101199101206
<dl class="switch">
101200101207

101208+
<dt>U+003C LESS-THAN SIGN (&lt;)</dt>
101209+
<dd>Append the <span>current input character</span> to the comment token's data. Switch to the
101210+
<span>comment less-than sign state</span>.</dd>
101211+
101201101212
<dt>U+002D HYPHEN-MINUS (-)</dt>
101202-
<dd>Switch to the <span>comment end dash state</span></dd>
101213+
<dd>Switch to the <span>comment end dash state</span>.</dd>
101203101214

101204101215
<dt>U+0000 NULL</dt>
101205101216
<dd><span>Parse error</span>. Append a U+FFFD REPLACEMENT CHARACTER character to the comment
@@ -101215,6 +101226,55 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
101215101226
</dl>
101216101227

101217101228

101229+
<h5><dfn>Comment less-than sign state</dfn></h5>
101230+
101231+
<p>Consume the <span>next input character</span>:</p>
101232+
101233+
<dl class="switch">
101234+
101235+
<dt>U+0021 EXCLAMATION MARK (!)</dt>
101236+
<dd>Append the <span>current input character</span> to the comment token's data. Switch to the
101237+
<span>comment less-than sign bang state</span>.</dd>
101238+
101239+
<dt>U+003C LESS-THAN SIGN (&lt;)</dt>
101240+
<dd>Append the <span>current input character</span> to the comment token's data.</dd>
101241+
101242+
<dt>Anything else</dt>
101243+
<dd><span>Reconsume</span> in the <span>comment state</span>.</dd>
101244+
101245+
</dl>
101246+
101247+
101248+
<h5><dfn>Comment less-than sign bang state</dfn></h5>
101249+
101250+
<p>Consume the <span>next input character</span>:</p>
101251+
101252+
<dl class="switch">
101253+
101254+
<dt>U+002D HYPHEN-MINUS (-)</dt>
101255+
<dd>Switch to the <span>comment less-than sign bang dash state</span>.</dd>
101256+
101257+
<dt>Anything else</dt>
101258+
<dd><span>Reconsume</span> in the <span>comment state</span>.</dd>
101259+
101260+
</dl>
101261+
101262+
101263+
<h5><dfn>Comment less-than sign bang dash state</dfn></h5>
101264+
101265+
<p>Consume the <span>next input character</span>:</p>
101266+
101267+
<dl class="switch">
101268+
101269+
<dt>U+002D HYPHEN-MINUS (-)</dt>
101270+
<dd><span>Parse error</span>. Switch to the <span>comment end state</span>.</dd>
101271+
101272+
<dt>Anything else</dt>
101273+
<dd><span>Reconsume</span> in the <span>comment end dash state</span>.</dd>
101274+
101275+
</dl>
101276+
101277+
101218101278
<h5><dfn>Comment end dash state</dfn></h5>
101219101279

101220101280
<p>Consume the <span>next input character</span>:</p>

0 commit comments

Comments
 (0)