mirror of
https://github.com/russross/blackfriday.git
synced 2024-03-22 13:40:34 +08:00
Fix bug in autolink termination
Detect the end of link when it is immediately followed by an element.
This commit is contained in:
parent
9fc8c9d866
commit
f2d43f69a4
|
@ -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 {
|
||||
|
|
|
@ -689,6 +689,9 @@ func TestAutoLink(t *testing.T) {
|
|||
|
||||
"(<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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user