Skip to content

Commit

Permalink
Make nested comments a parse error
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zcorpan committed May 31, 2016
1 parent 2568463 commit b4d672b
Showing 1 changed file with 69 additions and 9 deletions.
78 changes: 69 additions & 9 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -98254,14 +98254,21 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {

<h4>Comments</h4>

<p><dfn data-x="syntax-comments">Comments</dfn> must start with the four character sequence U+003C
LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS (<code
data-x="">&lt;!--</code>). Following this sequence, the comment may have <span
data-x="syntax-text">text</span>, with the additional restriction that the text must not start
with a single U+003E GREATER-THAN SIGN character (&gt;), nor start with a U+002D HYPHEN-MINUS
character (-) followed by a U+003E GREATER-THAN SIGN (&gt;) character. Finally, the comment must
be ended by the three character sequence U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E
GREATER-THAN SIGN (<code data-x="">--&gt;</code>).</p>
<p><dfn data-x="syntax-comments">Comments</dfn> must have the following format:</p>

<ol>

<li>The string "<code data-x="">&lt;!--</code>".</li>

<li>Optionally, <span data-x="syntax-text">text</span>, with the additional restriction that the
text must not start with the string "<code data-x="">&gt;</code>", nor start with the string
"<code data-x="">-></code>", nor contain the string "<code data-x="">&lt;!--</code>", nor end
with the string "<code data-x="">&lt;!</code>", nor end with the string "<code
data-x="">&lt;!-</code>".</li>

<li>The string "<code data-x="">--&gt;</code>".</li>

</ol>


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

<dl class="switch">

<dt>U+003C LESS-THAN SIGN (&lt;)</dt>
<dd>Append the <span>current input character</span> to the comment token's data. Switch to the
<span>comment less-than sign state</span>.</dd>

<dt>U+002D HYPHEN-MINUS (-)</dt>
<dd>Switch to the <span>comment end dash state</span></dd>
<dd>Switch to the <span>comment end dash state</span>.</dd>

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


<h5><dfn>Comment less-than sign state</dfn></h5>

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

<dl class="switch">

<dt>U+0021 EXCLAMATION MARK (!)</dt>
<dd>Append the <span>current input character</span> to the comment token's data. Switch to the
<span>comment less-than sign bang state</span>.</dd>

<dt>U+003C LESS-THAN SIGN (&lt;)</dt>
<dd>Append the <span>current input character</span> to the comment token's data.</dd>

<dt>Anything else</dt>
<dd><span>Reconsume</span> in the <span>comment state</span>.</dd>

</dl>


<h5><dfn>Comment less-than sign bang state</dfn></h5>

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

<dl class="switch">

<dt>U+002D HYPHEN-MINUS (-)</dt>
<dd>Switch to the <span>comment less-than sign bang dash state</span>.</dd>

<dt>Anything else</dt>
<dd><span>Reconsume</span> in the <span>comment state</span>.</dd>

</dl>


<h5><dfn>Comment less-than sign bang dash state</dfn></h5>

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

<dl class="switch">

<dt>U+002D HYPHEN-MINUS (-)</dt>
<dd><span>Parse error</span>. Switch to the <span>comment end state</span>.</dd>

<dt>Anything else</dt>
<dd><span>Reconsume</span> in the <span>comment end dash state</span>.</dd>

</dl>


<h5><dfn>Comment end dash state</dfn></h5>

<p>Consume the <span>next input character</span>:</p>
Expand Down

0 comments on commit b4d672b

Please sign in to comment.