Fix bug in autolink termination Detect the end of link when it is immediately followed by an element.
Vytautas Ĺ altenis vytas@rtfb.lt
Sat, 25 Jan 2014 21:59:38 +0200
2 files changed,
8 insertions(+),
1 deletions(-)
M
inline.go
→
inline.go
@@ -654,7 +654,7 @@ return 0
} linkEnd := 0 - for linkEnd < len(data) && !isspace(data[linkEnd]) { + for linkEnd < len(data) && !isEndOfLink(data[linkEnd]) { linkEnd++ }@@ -735,6 +735,10 @@ p.r.AutoLink(out, uLink.Bytes(), LINK_TYPE_NORMAL)
} return linkEnd - rewind +} + +func isEndOfLink(char byte) bool { + return isspace(char) || char == '<' } var validUris = [][]byte{[]byte("http://"), []byte("https://"), []byte("ftp://"), []byte("mailto://"), []byte("/")}
M
inline_test.go
→
inline_test.go
@@ -689,6 +689,9 @@ "<p>(<a href=\"http://www.fancy.com/A_B\">http://www.fancy.com/A_B</a> (</p>\n",
"(<a href=\"http://www.fancy.com/A_B\">http://www.fancy.com/A_B</a> (part two: <a href=\"http://www.fancy.com/A_B\">http://www.fancy.com/A_B</a>)).\n", "<p>(<a href=\"http://www.fancy.com/A_B\">http://www.fancy.com/A_B</a> (part two: <a href=\"http://www.fancy.com/A_B\">http://www.fancy.com/A_B</a>)).</p>\n", + + "http://www.foo.com<br />\n", + "<p><a href=\"http://www.foo.com\">http://www.foo.com</a><br /></p>\n", } doTestsInline(t, tests) }