diff --git a/modules/markup/html.go b/modules/markup/html.go index 7a5ca14aeb..56f63b8a76 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -623,10 +623,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 } } diff --git a/modules/templates/util_render_test.go b/modules/templates/util_render_test.go index c1d5e26f62..ea01612ac3 100644 --- a/modules/templates/util_render_test.go +++ b/modules/templates/util_render_test.go @@ -50,6 +50,11 @@ func TestApostrophesInMentions(t *testing.T) { assert.EqualValues(t, template.HTML("
@mention-user's comment
\n"), rendered) } +func TestNonExistantUserMention(t *testing.T) { + rendered := RenderMarkdownToHtml(context.Background(), "@ThisUserDoesNotExist @mention-user") + assert.EqualValues(t, template.HTML("@ThisUserDoesNotExist @mention-user
\n"), rendered) +} + func TestRenderCommitBody(t *testing.T) { type args struct { ctx context.Context