Skip to content

Commit

Permalink
Fix HTML comment parsing with - before closing --> (#286)
Browse files Browse the repository at this point in the history
Fixes #285.
  • Loading branch information
robinst authored Mar 6, 2024
1 parent a4d859c commit 6f94a99
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var ATTRIBUTEVALUESPEC = "(?:" + "\\s*=" + "\\s*" + ATTRIBUTEVALUE + ")";
var ATTRIBUTE = "(?:" + "\\s+" + ATTRIBUTENAME + ATTRIBUTEVALUESPEC + "?)";
var OPENTAG = "<" + TAGNAME + ATTRIBUTE + "*" + "\\s*/?>";
var CLOSETAG = "</" + TAGNAME + "\\s*[>]";
var HTMLCOMMENT = "<!-->|<!--->|<!--(?:[^-]|-[^-]|--[^>])*-->"
var HTMLCOMMENT = "<!-->|<!--->|<!--[\\s\\S]*?-->"
var PROCESSINGINSTRUCTION = "[<][?][\\s\\S]*?[?][>]";
var DECLARATION = "<![A-Za-z]+" + "[^>]*>";
var CDATA = "<!\\[CDATA\\[[\\s\\S]*?\\]\\]>";
Expand Down
16 changes: 16 additions & 0 deletions test/regression.txt
Original file line number Diff line number Diff line change
Expand Up @@ -502,3 +502,19 @@ x<!>
<p>x<!x></p>
<p>x&lt;!&gt;</p>
````````````````````````````````

#285
```````````````````````````````` example
foo <!-- test --->

foo <!-- test ---->

foo <!----->

foo <!-- test --> more -->
.
<p>foo <!-- test ---></p>
<p>foo <!-- test ----></p>
<p>foo <!-----></p>
<p>foo <!-- test --> more --&gt;</p>
````````````````````````````````

0 comments on commit 6f94a99

Please sign in to comment.