Skip to content

Commit 6f94a99

Browse files
authored
Fix HTML comment parsing with - before closing --> (#286)
Fixes #285.
1 parent a4d859c commit 6f94a99

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var ATTRIBUTEVALUESPEC = "(?:" + "\\s*=" + "\\s*" + ATTRIBUTEVALUE + ")";
2424
var ATTRIBUTE = "(?:" + "\\s+" + ATTRIBUTENAME + ATTRIBUTEVALUESPEC + "?)";
2525
var OPENTAG = "<" + TAGNAME + ATTRIBUTE + "*" + "\\s*/?>";
2626
var CLOSETAG = "</" + TAGNAME + "\\s*[>]";
27-
var HTMLCOMMENT = "<!-->|<!--->|<!--(?:[^-]|-[^-]|--[^>])*-->"
27+
var HTMLCOMMENT = "<!-->|<!--->|<!--[\\s\\S]*?-->"
2828
var PROCESSINGINSTRUCTION = "[<][?][\\s\\S]*?[?][>]";
2929
var DECLARATION = "<![A-Za-z]+" + "[^>]*>";
3030
var CDATA = "<!\\[CDATA\\[[\\s\\S]*?\\]\\]>";

test/regression.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,3 +502,19 @@ x<!>
502502
<p>x<!x></p>
503503
<p>x&lt;!&gt;</p>
504504
````````````````````````````````
505+
506+
#285
507+
```````````````````````````````` example
508+
foo <!-- test --->
509+
510+
foo <!-- test ---->
511+
512+
foo <!----->
513+
514+
foo <!-- test --> more -->
515+
.
516+
<p>foo <!-- test ---></p>
517+
<p>foo <!-- test ----></p>
518+
<p>foo <!-----></p>
519+
<p>foo <!-- test --> more --&gt;</p>
520+
````````````````````````````````

0 commit comments

Comments
 (0)