mirror of
https://github.com/russross/blackfriday.git
synced 2024-03-22 13:40:34 +08:00
panic fix (issue #33) with test case
This commit is contained in:
parent
472fe3a756
commit
ca82b8db3a
|
@ -181,7 +181,7 @@ const (
|
||||||
// '[': parse a link or an image or a footnote
|
// '[': parse a link or an image or a footnote
|
||||||
func link(p *parser, out *bytes.Buffer, data []byte, offset int) int {
|
func link(p *parser, out *bytes.Buffer, data []byte, offset int) int {
|
||||||
// no links allowed inside regular links, footnote, and deferred footnotes
|
// 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
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -410,6 +410,9 @@ func TestInlineLink(t *testing.T) {
|
||||||
|
|
||||||
"[link](/url/&query)\n",
|
"[link](/url/&query)\n",
|
||||||
"<p><a href=\"/url/&query\">link</a></p>\n",
|
"<p><a href=\"/url/&query\">link</a></p>\n",
|
||||||
|
|
||||||
|
"[[t]](/t)\n",
|
||||||
|
"<p><a href=\"/t\">[t]</a></p>\n",
|
||||||
}
|
}
|
||||||
doTestsInline(t, tests)
|
doTestsInline(t, tests)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user