fix: escape HTML tags in inline code blocks in description (#10897)

Fix rendering of repository descriptions containing HTML symbols inside Markdown inline code block. This patch escapes content within inline code blocks.

Resolves #10770.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10897
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: oidq <oidq@oidq.dev>
Co-committed-by: oidq <oidq@oidq.dev>
This commit is contained in:
oidq 2026-01-25 23:10:56 +01:00 committed by Gusted
parent 6412ee12d0
commit 8866bf2781
3 changed files with 73 additions and 1 deletions

View file

@ -300,7 +300,7 @@ func RenderDescriptionHTML(
descriptionLinkProcessor,
emojiShortCodeProcessor,
emojiProcessor,
}, content)
}, escapeInlineCodeBlocks(content))
}
// RenderEmoji for when we want to just process emoji and shortcodes
@ -1543,3 +1543,9 @@ func optionalRepoSlugAndInstancePath(ctx *RenderContext, text *string, fullURL,
}
}
}
// escapeInlineCodeBlocks escapes HTML symbols in contents of Markdown inline code blocks
// to prevent clashing with HTML parsing
func escapeInlineCodeBlocks(input string) string {
return InlineCodeBlockRegex.ReplaceAllStringFunc(input, html.EscapeString)
}