diff --git a/inline.go b/inline.go index d83404e..952aa63 100644 --- a/inline.go +++ b/inline.go @@ -654,7 +654,7 @@ func autoLink(p *parser, out *bytes.Buffer, data []byte, offset int) int { } linkEnd := 0 - for linkEnd < len(data) && !isspace(data[linkEnd]) { + for linkEnd < len(data) && !isEndOfLink(data[linkEnd]) { linkEnd++ } @@ -737,6 +737,10 @@ func autoLink(p *parser, out *bytes.Buffer, data []byte, offset int) int { return linkEnd - rewind } +func isEndOfLink(char byte) bool { + return isspace(char) || char == '<' +} + var validUris = [][]byte{[]byte("http://"), []byte("https://"), []byte("ftp://"), []byte("mailto://"), []byte("/")} func isSafeLink(link []byte) bool { diff --git a/inline_test.go b/inline_test.go index 7cb3cdf..a4be3ba 100644 --- a/inline_test.go +++ b/inline_test.go @@ -689,6 +689,9 @@ func TestAutoLink(t *testing.T) { "(http://www.fancy.com/A_B (part two: http://www.fancy.com/A_B)).\n", "
(http://www.fancy.com/A_B (part two: http://www.fancy.com/A_B)).
\n", + + "http://www.foo.com