mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-05-12 22:10:25 +00:00
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:
parent
6412ee12d0
commit
8866bf2781
3 changed files with 73 additions and 1 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue