parent
5feb1a6bff
commit
594edad213
5 changed files with 40 additions and 17 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/modules/markup/common"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
|
||||
"golang.org/x/net/html"
|
||||
"golang.org/x/net/html/atom"
|
||||
|
@ -171,6 +172,10 @@ func linkProcessor(ctx *RenderContext, node *html.Node) {
|
|||
}
|
||||
|
||||
uri := node.Data[m[0]:m[1]]
|
||||
remaining := node.Data[m[1]:]
|
||||
if util.IsLikelySplitLeftPart(remaining) {
|
||||
return
|
||||
}
|
||||
replaceContent(node, m[0], m[1], createLink(ctx, uri, uri, "" /*link*/))
|
||||
node = node.NextSibling.NextSibling
|
||||
}
|
||||
|
|
|
@ -206,6 +206,16 @@ func TestRender_links(t *testing.T) {
|
|||
test(
|
||||
"ftps://gitea.com",
|
||||
`<p>ftps://gitea.com</p>`)
|
||||
|
||||
t.Run("LinkSplit", func(t *testing.T) {
|
||||
input, _ := util.SplitStringAtByteN("http://10.1.2.3", 12)
|
||||
assert.Equal(t, "http://10…", input)
|
||||
test(input, "<p>http://10…</p>")
|
||||
|
||||
input, _ = util.SplitStringAtByteN("http://10.1.2.3", 13)
|
||||
assert.Equal(t, "http://10.…", input)
|
||||
test(input, "<p>http://10.…</p>")
|
||||
})
|
||||
}
|
||||
|
||||
func TestRender_email(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue