From 97535d7a15454fd10eab5bb1961537360f84a0a9 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Thu, 30 Sep 2021 11:47:56 +0200 Subject: [PATCH] Fix panic parsing list definition --- block.go | 2 +- markdown_test.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/block.go b/block.go index dcd61e6e..6712c027 100644 --- a/block.go +++ b/block.go @@ -1360,7 +1360,7 @@ gatherlines: if *flags&ListTypeDefinition != 0 && i < len(data)-1 { // is the next item still a part of this list? next := i - for next < len(data) && data[next] != '\n' { + for next < len(data)-1 && data[next] != '\n' { next++ } for next < len(data)-1 && data[next] == '\n' { diff --git a/markdown_test.go b/markdown_test.go index 078dcda3..bed6e59c 100644 --- a/markdown_test.go +++ b/markdown_test.go @@ -34,6 +34,10 @@ func TestDocument(t *testing.T) { // https://github.com/russross/blackfriday/issues/173 " [", "

[

\n", + + // This should't panic. + "text\n\n:item: **text**\ntext\n", + "
\n
text
\n
\n\n

:item: text\ntext

\n", } doTests(t, tests) }