diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2024-03-01 18:16:19 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-01 10:16:19 +0000 |
commit | fb42972c057364a1dc99dfb528554e7a94415be7 (patch) | |
tree | 162d9e043c62df788f438ae2bb65983e301f8517 /templates | |
parent | cb52b17f92e2d2293f7c003649743464492bca48 (diff) | |
download | gitea-fb42972c057364a1dc99dfb528554e7a94415be7.tar.gz gitea-fb42972c057364a1dc99dfb528554e7a94415be7.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.
Diffstat (limited to 'templates')
-rw-r--r-- | templates/base/alert.tmpl | 8 | ||||
-rw-r--r-- | templates/base/alert_details.tmpl | 2 | ||||
-rw-r--r-- | templates/mail/issue/default.tmpl | 2 | ||||
-rw-r--r-- | templates/repo/commit_page.tmpl | 2 | ||||
-rw-r--r-- | templates/repo/issue/view_content/comments.tmpl | 2 | ||||
-rw-r--r-- | templates/repo/settings/webhook/base_list.tmpl | 2 | ||||
-rw-r--r-- | templates/status/500.tmpl | 2 |
7 files changed, 10 insertions, 10 deletions
diff --git a/templates/base/alert.tmpl b/templates/base/alert.tmpl index 160584f769..760d3bfa2c 100644 --- a/templates/base/alert.tmpl +++ b/templates/base/alert.tmpl @@ -1,20 +1,20 @@ {{if .Flash.ErrorMsg}} <div class="ui negative message flash-message flash-error"> - <p>{{.Flash.ErrorMsg | Str2html}}</p> + <p>{{.Flash.ErrorMsg | SanitizeHTML}}</p> </div> {{end}} {{if .Flash.SuccessMsg}} <div class="ui positive message flash-message flash-success"> - <p>{{.Flash.SuccessMsg | Str2html}}</p> + <p>{{.Flash.SuccessMsg | SanitizeHTML}}</p> </div> {{end}} {{if .Flash.InfoMsg}} <div class="ui info message flash-message flash-info"> - <p>{{.Flash.InfoMsg | Str2html}}</p> + <p>{{.Flash.InfoMsg | SanitizeHTML}}</p> </div> {{end}} {{if .Flash.WarningMsg}} <div class="ui warning message flash-message flash-warning"> - <p>{{.Flash.WarningMsg | Str2html}}</p> + <p>{{.Flash.WarningMsg | SanitizeHTML}}</p> </div> {{end}} diff --git a/templates/base/alert_details.tmpl b/templates/base/alert_details.tmpl index 1d7ec15dc0..6801c8240f 100644 --- a/templates/base/alert_details.tmpl +++ b/templates/base/alert_details.tmpl @@ -2,6 +2,6 @@ <details> <summary>{{.Summary}}</summary> <code> - {{.Details | Str2html}} + {{.Details | SanitizeHTML}} </code> </details> diff --git a/templates/mail/issue/default.tmpl b/templates/mail/issue/default.tmpl index 79dbe897cc..10fa0f1ffc 100644 --- a/templates/mail/issue/default.tmpl +++ b/templates/mail/issue/default.tmpl @@ -58,7 +58,7 @@ {{.locale.Tr "mail.issue.action.new" .Doer.Name .Issue.Index}} {{end}} {{else}} - {{.Body | Str2html}} + {{.Body | SanitizeHTML}} {{end -}} {{- range .ReviewComments}} <hr> diff --git a/templates/repo/commit_page.tmpl b/templates/repo/commit_page.tmpl index 115ee92955..7892a57163 100644 --- a/templates/repo/commit_page.tmpl +++ b/templates/repo/commit_page.tmpl @@ -276,7 +276,7 @@ <span class="text grey" id="note-authored-time">{{TimeSince .NoteCommit.Author.When ctx.Locale}}</span> </div> <div class="ui bottom attached info segment git-notes"> - <pre class="commit-body">{{.NoteRendered | Str2html}}</pre> + <pre class="commit-body">{{.NoteRendered | SanitizeHTML}}</pre> </div> {{end}} {{template "repo/diff/box" .}} diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index 36ef5751ae..66ecc544d2 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -162,7 +162,7 @@ </span> <div class="detail"> {{svg "octicon-git-commit"}} - <span class="text grey muted-links">{{.Content | Str2html}}</span> + <span class="text grey muted-links">{{.Content | SanitizeHTML}}</span> </div> </div> {{else if eq .Type 7}} diff --git a/templates/repo/settings/webhook/base_list.tmpl b/templates/repo/settings/webhook/base_list.tmpl index 5a3fc0e7b8..00f9a48ba7 100644 --- a/templates/repo/settings/webhook/base_list.tmpl +++ b/templates/repo/settings/webhook/base_list.tmpl @@ -10,7 +10,7 @@ <div class="ui attached segment"> <div class="ui list"> <div class="item"> - {{.Description | Str2html}} + {{.Description | SanitizeHTML}} </div> {{range .Webhooks}} <div class="item truncated-item-container"> diff --git a/templates/status/500.tmpl b/templates/status/500.tmpl index d6cff28174..a92933c153 100644 --- a/templates/status/500.tmpl +++ b/templates/status/500.tmpl @@ -1,5 +1,5 @@ {{/* This page should only depend the minimal template functions/variables, to avoid triggering new panics. -* base template functions: AppName, AssetUrlPrefix, AssetVersion, AppSubUrl, ThemeName, Str2html +* base template functions: AppName, AssetUrlPrefix, AssetVersion, AppSubUrl, ThemeName, SanitizeHTML * ctx.Locale * .Flash * .ErrorMsg |