panic fix (issue #33) with test case

This commit is contained in:
Russ Ross 2013-09-11 12:47:43 -06:00
parent 472fe3a756
commit ca82b8db3a
2 changed files with 4 additions and 1 deletions

View File

@ -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
}

View File

@ -410,6 +410,9 @@ func TestInlineLink(t *testing.T) {
"[link](/url/&query)\n",
"<p><a href=\"/url/&amp;query\">link</a></p>\n",
"[[t]](/t)\n",
"<p><a href=\"/t\">[t]</a></p>\n",
}
doTestsInline(t, tests)
}