summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-03-01 11:16:19 +0100
committerEarl Warren <contact@earl-warren.org>2024-03-06 05:10:45 +0100
commit2892aaab0258a606719ad7f71a5087aba3549325 (patch)
tree6338d320723691118cd5005bf7b1e10234414c2b /routers
parentRefactor some Str2html code (followup) (diff)
downloadforgejo-2892aaab0258a606719ad7f71a5087aba3549325.tar.xz
forgejo-2892aaab0258a606719ad7f71a5087aba3549325.zip
Rename Str2html to SanitizeHTML and clarify its behavior (#29516)
Str2html was abused a lot. So use a proper name for it: SanitizeHTML And add some tests to show its behavior. (cherry picked from commit fb42972c057364a1dc99dfb528554e7a94415be7) Conflicts: docs/content/administration/mail-templates.en-us.md docs/content/administration/mail-templates.zh-cn.md prefer their version always
Diffstat (limited to 'routers')
-rw-r--r--routers/web/feed/convert.go4
-rw-r--r--routers/web/org/projects.go4
-rw-r--r--routers/web/repo/issue.go2
3 files changed, 5 insertions, 5 deletions
diff --git a/routers/web/feed/convert.go b/routers/web/feed/convert.go
index f4079f188f..743465082e 100644
--- a/routers/web/feed/convert.go
+++ b/routers/web/feed/convert.go
@@ -65,7 +65,7 @@ func renderMarkdown(ctx *context.Context, act *activities_model.Action, content
}
markdown, err := markdown.RenderString(markdownCtx, content)
if err != nil {
- return templates.Str2html(content) // old code did so: use Str2html to render in tmpl
+ return templates.SanitizeHTML(content) // old code did so: use SanitizeHTML to render in tmpl
}
return markdown
}
@@ -244,7 +244,7 @@ func feedActionsToFeedItems(ctx *context.Context, actions activities_model.Actio
}
}
if len(content) == 0 {
- content = templates.Str2html(desc)
+ content = templates.SanitizeHTML(desc)
}
// It's a common practice for feed generators to use plain text titles.
diff --git a/routers/web/org/projects.go b/routers/web/org/projects.go
index f2db4a4579..82cd91997a 100644
--- a/routers/web/org/projects.go
+++ b/routers/web/org/projects.go
@@ -105,7 +105,7 @@ func Projects(ctx *context.Context) {
}
for _, project := range projects {
- project.RenderedContent = templates.Str2html(project.Description) // FIXME: is it right? why not render?
+ project.RenderedContent = templates.SanitizeHTML(project.Description) // FIXME: is it right? why not render?
}
err = shared_user.LoadHeaderCount(ctx)
@@ -396,7 +396,7 @@ func ViewProject(ctx *context.Context) {
}
}
- project.RenderedContent = templates.Str2html(project.Description) // FIXME: is it right? why not render?
+ project.RenderedContent = templates.SanitizeHTML(project.Description) // FIXME: is it right? why not render?
ctx.Data["LinkedPRs"] = linkedPrsMap
ctx.Data["PageIsViewProjects"] = true
ctx.Data["CanWriteProjects"] = canWriteProjects(ctx)
diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go
index 2ba40fcd57..e74049810a 100644
--- a/routers/web/repo/issue.go
+++ b/routers/web/repo/issue.go
@@ -1770,7 +1770,7 @@ func ViewIssue(ctx *context.Context) {
// so "|" is used as delimeter to mark the new format
if comment.Content[0] != '|' {
// handle old time comments that have formatted text stored
- comment.RenderedContent = templates.Str2html(comment.Content)
+ comment.RenderedContent = templates.SanitizeHTML(comment.Content)
comment.Content = ""
} else {
// else it's just a duration in seconds to pass on to the frontend