diff --git a/inline_test.go b/inline_test.go index f045201c..40afe7bc 100644 --- a/inline_test.go +++ b/inline_test.go @@ -1286,6 +1286,14 @@ func TestSkipHTML(t *testing.T) { }, TestParams{Flags: html.SkipHTML}) } +func TestTagLengthUnclosedAngle(t *testing.T) { + // Unclosed angle brackets with short tag names should not lose content + doTestsParam(t, []string{ + "click click <a href content

\n", + }, TestParams{Flags: html.SkipHTML}) +} + func TestInlineMath(t *testing.T) { doTestsParam(t, []string{ "$a_b$", diff --git a/parser/inline.go b/parser/inline.go index d526ce22..88fc3181 100644 --- a/parser/inline.go +++ b/parser/inline.go @@ -1073,10 +1073,11 @@ func tagLength(data []byte) (autolink autolinkType, end int) { // one of the forbidden chars has been found autolink = notAutolink } - i += bytes.IndexByte(data[i:], '>') - if i < 0 { + j = bytes.IndexByte(data[i:], '>') + if j < 0 { return autolink, 0 } + i += j return autolink, i + 1 }