Skip to content

Commit

Permalink
fix infinite loop with empty list definition (fixes #311)
Browse files Browse the repository at this point in the history
  • Loading branch information
kjk committed Jul 29, 2024
1 parent afa4a46 commit a2a9c4f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion parser/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -1652,7 +1652,9 @@ func (p *Parser) paragraph(data []byte) int {
if p.extensions&DefinitionLists != 0 {
if i < len(data)-1 && data[i+1] == ':' {
listLen := p.list(data[prev:], ast.ListTypeDefinition, 0, '.')
return prev + listLen
if listLen > 0 {
return prev + listLen
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import (
"testing"
)

func TestBug311(t *testing.T) {
str := "~~~~\xb4~\x94~\x94~\xd1\r\r:\xb4\x94\x94~\x9f~\xb4~\x94~\x94\x94"
p := New()
p.Parse([]byte(str))
}

func TestIsFenceLine(t *testing.T) {
tests := []struct {
data []byte
Expand Down

0 comments on commit a2a9c4f

Please # to comment.