Skip to content

Commit

Permalink
Merge pull request fb55#49 from AndreasMadsen/long-comment
Browse files Browse the repository at this point in the history
[tokenizer] don't reset comment state in case of long endings
  • Loading branch information
fb55 committed Jun 6, 2013
2 parents 231a746 + 7ef5de8 commit 623cd89
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/Tokenizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ Tokenizer.prototype.write = function(chunk){
this._cbs.oncomment(this._buffer.substring(this._sectionStart, this._index - 2));
this._state = TEXT;
this._sectionStart = this._index + 1;
} else if (c === '-') {
// Keep the state at AFTER_COMMENT_2
} else {
this._state = IN_COMMENT;
}
Expand Down
20 changes: 20 additions & 0 deletions tests/Events/12-long-comment-end.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "Long comment ending",
"options": {
"handler": {},
"parser": {}
},
"html": "<meta id='before'><!-- text ---><meta id='after'>",
"expected": [
{ "event": "opentagname", "data": [ "meta" ] },
{ "event": "attribute", "data": [ "id", "before" ] },
{ "event": "opentag", "data": [ "meta", {"id": "before"} ] },
{ "event": "closetag", "data": [ "meta" ] },
{ "event": "comment", "data": [ " text -" ] },
{ "event": "commentend", "data": [] },
{ "event": "opentagname", "data": [ "meta" ] },
{ "event": "attribute", "data": [ "id", "after" ] },
{ "event": "opentag", "data": [ "meta", {"id": "after"} ] },
{ "event": "closetag", "data": [ "meta" ] }
]
}

0 comments on commit 623cd89

Please sign in to comment.