Skip to content

Allow dashes in comments #1356

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

Merged
merged 3 commits into from
Jun 20, 2016
Merged
Changes from all 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
159 changes: 93 additions & 66 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -1497,10 +1497,11 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d
<dd>

<p>When a user agent based on XML is connected to an HTML parser, it is possible that certain
invariants that XML enforces, such as comments never containing two consecutive hyphens, will be
violated by an HTML file. Handling this can require that the parser coerce the HTML DOM into an
XML-compatible infoset. Most syntax constructs that require such handling are considered
invalid.</p>
invariants that XML enforces, such as element or attribute names never contain multiple colons,
will be violated by an HTML file. Handling this can require that the parser coerce the HTML DOM
into an XML-compatible infoset. Most syntax constructs that require such handling are considered
invalid. (Comments containing two consecutive hyphens, or ending with a hyphen, are exceptions
that are allowed in the HTML syntax.)</p>

</dd>

Expand Down Expand Up @@ -98253,15 +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, nor contain two consecutive U+002D
HYPHEN-MINUS characters (<code data-x="">--</code>), nor end with a U+002D HYPHEN-MINUS 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 @@ -101160,21 +101167,11 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
<dt>U+002D HYPHEN-MINUS (-)</dt>
<dd>Switch to the <span>comment start dash state</span>.</dd>

<dt>U+0000 NULL</dt>
<dd><span>Parse error</span>. Append a U+FFFD REPLACEMENT CHARACTER character to the comment
token's data. Switch to the <span>comment state</span>.</dd>

<dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
<dd><span>Parse error</span>. Switch to the <span>data state</span>. Emit the comment token.</dd>
<!-- see comment in comment end state -->

<dt>EOF</dt>
<dd><span>Parse error</span>. Emit the comment token. <span>Reconsume</span> in the <span>data
state</span>.</dd>

<dt>Anything else</dt>
<dd>Append the <span>current input character</span> to the comment token's data. Switch to the
<span>comment state</span>.</dd>
<dd><span>Reconsume</span> in the <span>comment state</span>.</dd>

</dl>

Expand All @@ -101188,20 +101185,16 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
<dt>U+002D HYPHEN-MINUS (-)</dt>
<dd>Switch to the <span>comment end state</span></dd>

<dt>U+0000 NULL</dt>
<dd><span>Parse error</span>. Append a U+002D HYPHEN-MINUS character (-) and a U+FFFD REPLACEMENT
CHARACTER character to the comment token's data. Switch to the <span>comment state</span>.</dd>

<dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
<dd><span>Parse error</span>. Switch to the <span>data state</span>. Emit the comment token.</dd>

<dt>EOF</dt>
<dd><span>Parse error</span>. Emit the comment token. <span>Reconsume</span> in the <span>data
state</span>.</dd> <!-- see comment in comment end state -->
state</span>.</dd>

<dt>Anything else</dt>
<dd>Append a U+002D HYPHEN-MINUS character (-) and the <span>current input character</span> to
the comment token's data. Switch to the <span>comment state</span>.</dd>
<dd>Append a U+002D HYPHEN-MINUS character (-) to the comment token's data.
<span>Reconsume</span> in the <span>comment state</span>.</dd>

</dl>

Expand All @@ -101212,23 +101205,76 @@ 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
token's data.</dd>

<dt>EOF</dt>
<dd><span>Parse error</span>. Switch to the <span>data state</span>. Emit the comment token.
Reconsume the EOF character.</dd> <!-- see comment in comment end state -->
<dd><span>Parse error</span>. Emit the comment token. <span>Reconsume</span> in the <span>data
state</span>.</dd>

<dt>Anything else</dt>
<dd>Append the <span>current input character</span> to the comment token's data.</dd>

</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 All @@ -101238,17 +101284,13 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
<dt>U+002D HYPHEN-MINUS (-)</dt>
<dd>Switch to the <span>comment end state</span></dd>

<dt>U+0000 NULL</dt>
<dd><span>Parse error</span>. Append a U+002D HYPHEN-MINUS character (-) and a U+FFFD REPLACEMENT
CHARACTER character to the comment token's data. Switch to the <span>comment state</span>.</dd>

<dt>EOF</dt>
<dd><span>Parse error</span>. Switch to the <span>data state</span>. Emit the comment token.
Reconsume the EOF character.</dd> <!-- see comment in comment end state -->
<dd><span>Parse error</span>. Emit the comment token. <span>Reconsume</span> in the <span>data
state</span>.</dd>

<dt>Anything else</dt>
<dd>Append a U+002D HYPHEN-MINUS character (-) and the <span>current input character</span> to
the comment token's data. Switch to the <span>comment state</span>.</dd>
<dd>Append a U+002D HYPHEN-MINUS character (-) to the comment token's data.
<span>Reconsume</span> in the <span>comment state</span>.</dd>

</dl>

Expand All @@ -101262,28 +101304,19 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
<dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
<dd>Switch to the <span>data state</span>. Emit the comment token.</dd>

<dt>U+0000 NULL</dt>
<dd><span>Parse error</span>. Append two U+002D HYPHEN-MINUS characters (-) and a U+FFFD
REPLACEMENT CHARACTER character to the comment token's data. Switch to the <span>comment
state</span>.</dd>

<dt>U+0021 EXCLAMATION MARK (!)</dt>
<dd><span>Parse error</span>. Switch to the <span>comment end bang state</span>.</dd>
<dd>Switch to the <span>comment end bang state</span>.</dd>

<dt>U+002D HYPHEN-MINUS (-)</dt>
<dd><span>Parse error</span>. Append a U+002D HYPHEN-MINUS character (-) to the comment token's
data.</dd>
<dd>Append a U+002D HYPHEN-MINUS character (-) to the comment token's data.</dd>

<dt>EOF</dt>
<dd><span>Parse error</span>. Emit the comment token. <span>Reconsume</span> in the <span>data
state</span>.</dd> <!-- For security reasons: otherwise, hostile user could put a
<script> in a comment e.g. in a blog comment and then DOS the server so that the end tag isn't
read, and then the commented <script> tag would be treated as live code -->
state</span>.</dd>

<dt>Anything else</dt>
<dd><span>Parse error</span>. Append two U+002D HYPHEN-MINUS characters (-) and the <span>current
input character</span> to the comment token's data. Switch to the <span>comment
state</span>.</dd>
<dd>Append two U+002D HYPHEN-MINUS characters (-) to the comment token's data.
<span>Reconsume</span> in the <span>comment state</span>.</dd>

</dl>

Expand All @@ -101299,21 +101332,15 @@ dictionary <dfn>StorageEventInit</dfn> : <span>EventInit</span> {
the comment token's data. Switch to the <span>comment end dash state</span>.</dd>

<dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
<dd>Switch to the <span>data state</span>. Emit the comment token.</dd>

<dt>U+0000 NULL</dt>
<dd><span>Parse error</span>. Append two U+002D HYPHEN-MINUS characters (-), a U+0021 EXCLAMATION
MARK character (!), and a U+FFFD REPLACEMENT CHARACTER character to the comment token's data.
Switch to the <span>comment state</span>.</dd>
<dd><span>Parse error</span>. Switch to the <span>data state</span>. Emit the comment token.</dd>

<dt>EOF</dt>
<dd><span>Parse error</span>. Emit the comment token. <span>Reconsume</span> in the <span>data
state</span>.</dd> <!-- see comment in comment end state -->
state</span>.</dd>

<dt>Anything else</dt>
<dd>Append two U+002D HYPHEN-MINUS characters (-), a U+0021 EXCLAMATION MARK character (!), and
the <span>current input character</span> to the comment token's data. Switch to the <span>comment
state</span>.</dd>
<dd>Append two U+002D HYPHEN-MINUS characters (-) and a U+0021 EXCLAMATION MARK character (!) to
the comment token's data. <span>Reconsume</span> in the <span>comment state</span>.</dd>

</dl>

Expand Down