mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
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.
This commit is contained in:
@@ -64,7 +64,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
|
||||
}
|
||||
@@ -243,7 +243,7 @@ func feedActionsToFeedItems(ctx *context.Context, actions activities_model.Actio
|
||||
}
|
||||
}
|
||||
if len(content) == 0 {
|
||||
content = templates.Str2html(desc)
|
||||
content = templates.SanitizeHTML(desc)
|
||||
}
|
||||
|
||||
items = append(items, &feeds.Item{
|
||||
|
@@ -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)
|
||||
|
@@ -1761,7 +1761,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
|
||||
|
Reference in New Issue
Block a user