From ca82b8db3a85c5da858a1ec7c344872626ea2e81 Mon Sep 17 00:00:00 2001 From: Russ Ross Date: Wed, 11 Sep 2013 12:47:43 -0600 Subject: [PATCH] panic fix (issue #33) with test case --- inline.go | 2 +- inline_test.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/inline.go b/inline.go index 455f8fe..0e7cb86 100644 --- a/inline.go +++ b/inline.go @@ -181,7 +181,7 @@ const ( // '[': parse a link or an image or a footnote func link(p *parser, out *bytes.Buffer, data []byte, offset int) int { // no links allowed inside regular links, footnote, and deferred footnotes - if p.insideLink && (data[offset-1] == '[' || data[offset+1] == '^') { + if p.insideLink && (offset > 0 && data[offset-1] == '[' || len(data)-1 > offset && data[offset+1] == '^') { return 0 } diff --git a/inline_test.go b/inline_test.go index f7bc336..b7a1688 100644 --- a/inline_test.go +++ b/inline_test.go @@ -410,6 +410,9 @@ func TestInlineLink(t *testing.T) { "[link](/url/&query)\n", "

link

\n", + + "[[t]](/t)\n", + "

[t]

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