diff options
author | Giteabot <teabot@gitea.io> | 2024-05-02 09:48:24 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-02 09:48:24 +0800 |
commit | ac91bb27ffaad293f86b8160ed1d90159df6242f (patch) | |
tree | 0bb8daa77cdddaaa4a2f3c0cb2598f1500227fce /modules/markup/html.go | |
parent | 97a7c04a8fc4747d32af84fca3d068425ab33768 (diff) | |
download | gitea-ac91bb27ffaad293f86b8160ed1d90159df6242f.tar.gz gitea-ac91bb27ffaad293f86b8160ed1d90159df6242f.zip |
Fix markdown rendering when mentioning users (#30795) (#30810)
Backport #30795 by wxiaoguang
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'modules/markup/html.go')
-rw-r--r-- | modules/markup/html.go | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/modules/markup/html.go b/modules/markup/html.go index cef643bf18..5ae0cc8755 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -591,17 +591,16 @@ func replaceContentList(node *html.Node, i, j int, newNodes []*html.Node) { func mentionProcessor(ctx *RenderContext, node *html.Node) { start := 0 - next := node.NextSibling - for node != nil && node != next && start < len(node.Data) { - // We replace only the first mention; other mentions will be addressed later - found, loc := references.FindFirstMentionBytes([]byte(node.Data[start:])) + for node != nil { + found, loc := references.FindFirstMentionBytes(util.UnsafeStringToBytes(node.Data[start:])) if !found { - return + node = node.NextSibling + start = 0 + continue } loc.Start += start loc.End += start mention := node.Data[loc.Start:loc.End] - var teams string teams, ok := ctx.Metas["teams"] // FIXME: util.URLJoin may not be necessary here: // - setting.AppURL is defined to have a terminal '/' so unless mention[1:] @@ -623,10 +622,10 @@ func mentionProcessor(ctx *RenderContext, node *html.Node) { if DefaultProcessorHelper.IsUsernameMentionable != nil && DefaultProcessorHelper.IsUsernameMentionable(ctx.Ctx, mentionedUsername) { replaceContent(node, loc.Start, loc.End, createLink(util.URLJoin(ctx.Links.Prefix(), mentionedUsername), mention, "mention")) node = node.NextSibling.NextSibling + start = 0 } else { - node = node.NextSibling + start = loc.End } - start = 0 } } |