Skip to content
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

fix: infinite loop regression in literal (parse/ast) mode #620

Merged
merged 2 commits into from
Nov 11, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
fix: ensure StartTagToken and StartExpressionToken are always handled…
… literally
  • Loading branch information
natemoo-re committed Nov 11, 2022
commit 6908b2b04c78b3931c91b30b28096453cb04df0e
16 changes: 10 additions & 6 deletions internal/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -2672,16 +2672,22 @@ func frontmatterIM(p *parser) bool {
func inLiteralIM(p *parser) bool {
shouldExit := p.exitLiteralIM()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Immediately check if we should exit after this token is handled

switch p.tok.Type {
case ErrorToken:
// Stop parsing.
case TextToken:
p.addText(p.tok.Data)
case StartTagToken:
p.addElement()
if p.hasSelfClosingToken {
p.oe.pop()
p.acknowledgeSelfClosingTag()
}
// always continue `inLiteralIM`
return true
case StartExpressionToken:
p.addExpression()
// always continue `inLiteralIM`
return true
case ErrorToken:
// Stop parsing.
case TextToken:
p.addText(p.tok.Data)
case CommentToken:
p.addChild(&Node{
Type: CommentNode,
Expand All @@ -2691,8 +2697,6 @@ func inLiteralIM(p *parser) bool {
case EndTagToken:
p.addLoc()
p.oe.pop()
case StartExpressionToken:
p.addExpression()
case EndExpressionToken:
p.addLoc()
p.oe.pop()
Expand Down