mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
revert: "fix: markdown rendering improvements" (#27979)
This reverts commit 07f79af65b ("fix:
markdown rendering improvements").
The revert was applied cleanly with `git revert` and restores the
notification rendering pipeline to its prior state, including:
- `coderd/notifications/dispatch/smtp.go` and `smtp/html.gotmpl`
- `coderd/notifications/notifier.go` and `render/gotmpl.go`
- Removal of `coderd/notifications/render/sanitize_test.go` and
`smtp_internal_test.go` additions
- Regenerated SMTP golden templates under
`coderd/notifications/testdata/`
`go build ./coderd/notifications/...` passes on the reverted tree.
---
_This PR was generated by Coder Agents on behalf of @jdomeracki-coder._
This commit is contained in:
@@ -114,29 +114,10 @@ func PlaintextFromMarkdown(markdown string) (string, error) {
|
||||
}
|
||||
|
||||
func HTMLFromMarkdown(markdown string) string {
|
||||
return renderHTMLFromMarkdown(markdown, parser.CommonExtensions|parser.HardLineBreak, html.CommonFlags|html.SkipHTML)
|
||||
}
|
||||
|
||||
// HTMLFromMarkdownSafe renders Markdown to HTML with additional security
|
||||
// hardening for content that may include user-controlled values (e.g.
|
||||
// notification emails): autolinks are disabled so that only explicit Markdown
|
||||
// link syntax produces <a> tags, and Safelink drops links whose scheme is not
|
||||
// http/https/ftp/mailto.
|
||||
//
|
||||
// The hardening is scoped to this function. HTMLFromMarkdown renders
|
||||
// admin-authored deployment text (OIDCConfig.SignupsDisabledText) and keeps the
|
||||
// standard flags so links with custom schemes (e.g. slack://) still render.
|
||||
func HTMLFromMarkdownSafe(markdown string) string {
|
||||
extensions := parser.CommonExtensions | parser.HardLineBreak
|
||||
extensions &^= parser.Autolink
|
||||
return renderHTMLFromMarkdown(markdown, extensions, html.CommonFlags|html.SkipHTML|html.Safelink)
|
||||
}
|
||||
|
||||
func renderHTMLFromMarkdown(markdown string, extensions parser.Extensions, flags html.Flags) string {
|
||||
p := parser.NewWithExtensions(extensions)
|
||||
p := parser.NewWithExtensions(parser.CommonExtensions | parser.HardLineBreak) // Added HardLineBreak.
|
||||
doc := p.Parse([]byte(markdown))
|
||||
renderer := html.NewRenderer(html.RendererOptions{
|
||||
Flags: flags,
|
||||
Flags: html.CommonFlags | html.SkipHTML,
|
||||
})
|
||||
return string(bytes.TrimSpace(gomarkdown.Render(doc, renderer)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user