Skip to content

Commit c9d0e63

Browse files
authored
Remove unnecessary "Str2html" modifier from templates (#29319)
Follow #29165
1 parent 5ed17d9 commit c9d0e63

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+121
-120
lines changed

routers/web/auth/oauth.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"errors"
1010
"fmt"
1111
"html"
12+
"html/template"
1213
"io"
1314
"net/http"
1415
"net/url"
@@ -499,11 +500,11 @@ func AuthorizeOAuth(ctx *context.Context) {
499500
ctx.Data["Scope"] = form.Scope
500501
ctx.Data["Nonce"] = form.Nonce
501502
if user != nil {
502-
ctx.Data["ApplicationCreatorLinkHTML"] = fmt.Sprintf(`<a href="%s">@%s</a>`, html.EscapeString(user.HomeLink()), html.EscapeString(user.Name))
503+
ctx.Data["ApplicationCreatorLinkHTML"] = template.HTML(fmt.Sprintf(`<a href="%s">@%s</a>`, html.EscapeString(user.HomeLink()), html.EscapeString(user.Name)))
503504
} else {
504-
ctx.Data["ApplicationCreatorLinkHTML"] = fmt.Sprintf(`<a href="%s">%s</a>`, html.EscapeString(setting.AppSubURL+"/"), html.EscapeString(setting.AppName))
505+
ctx.Data["ApplicationCreatorLinkHTML"] = template.HTML(fmt.Sprintf(`<a href="%s">%s</a>`, html.EscapeString(setting.AppSubURL+"/"), html.EscapeString(setting.AppName)))
505506
}
506-
ctx.Data["ApplicationRedirectDomainHTML"] = "<strong>" + html.EscapeString(form.RedirectURI) + "</strong>"
507+
ctx.Data["ApplicationRedirectDomainHTML"] = template.HTML("<strong>" + html.EscapeString(form.RedirectURI) + "</strong>")
507508
// TODO document SESSION <=> FORM
508509
err = ctx.Session.Set("client_id", app.ClientID)
509510
if err != nil {

templates/admin/dashboard.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="admin-setting-content">
33
{{if .NeedUpdate}}
44
<div class="ui negative message flash-error">
5-
<p>{{(ctx.Locale.Tr "admin.dashboard.new_version_hint" .RemoteVersion AppVer) | Str2html}}</p>
5+
<p>{{ctx.Locale.Tr "admin.dashboard.new_version_hint" .RemoteVersion AppVer}}</p>
66
</div>
77
{{end}}
88
<h4 class="ui top attached header">

templates/code/searchcombo.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</div>
88
{{else if .SearchResults}}
99
<h3>
10-
{{ctx.Locale.Tr "explore.code_search_results" (.Keyword|Escape) | Str2html}}
10+
{{ctx.Locale.Tr "explore.code_search_results" (.Keyword|Escape)}}
1111
</h3>
1212
{{template "code/searchresults" .}}
1313
{{else if .Keyword}}

templates/home.tmpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
{{svg "octicon-flame"}} {{ctx.Locale.Tr "startpage.install"}}
1818
</h1>
1919
<p class="large">
20-
{{ctx.Locale.Tr "startpage.install_desc" | Str2html}}
20+
{{ctx.Locale.Tr "startpage.install_desc"}}
2121
</p>
2222
</div>
2323
<div class="eight wide center column">
2424
<h1 class="hero ui icon header">
2525
{{svg "octicon-device-desktop"}} {{ctx.Locale.Tr "startpage.platform"}}
2626
</h1>
2727
<p class="large">
28-
{{ctx.Locale.Tr "startpage.platform_desc" | Str2html}}
28+
{{ctx.Locale.Tr "startpage.platform_desc"}}
2929
</p>
3030
</div>
3131
</div>
@@ -35,15 +35,15 @@
3535
{{svg "octicon-rocket"}} {{ctx.Locale.Tr "startpage.lightweight"}}
3636
</h1>
3737
<p class="large">
38-
{{ctx.Locale.Tr "startpage.lightweight_desc" | Str2html}}
38+
{{ctx.Locale.Tr "startpage.lightweight_desc"}}
3939
</p>
4040
</div>
4141
<div class="eight wide center column">
4242
<h1 class="hero ui icon header">
4343
{{svg "octicon-code"}} {{ctx.Locale.Tr "startpage.license"}}
4444
</h1>
4545
<p class="large">
46-
{{ctx.Locale.Tr "startpage.license_desc" | Str2html}}
46+
{{ctx.Locale.Tr "startpage.license_desc"}}
4747
</p>
4848
</div>
4949
</div>

templates/mail/auth/activate.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
{{$activate_url := printf "%suser/activate?code=%s" AppUrl (QueryEscape .Code)}}
1010
<body>
11-
<p>{{.locale.Tr "mail.activate_account.text_1" (.DisplayName|DotEscape) AppName | Str2html}}</p><br>
12-
<p>{{.locale.Tr "mail.activate_account.text_2" .ActiveCodeLives | Str2html}}</p><p><a href="{{$activate_url}}">{{$activate_url}}</a></p><br>
11+
<p>{{.locale.Tr "mail.activate_account.text_1" (.DisplayName|DotEscape) AppName}}</p><br>
12+
<p>{{.locale.Tr "mail.activate_account.text_2" .ActiveCodeLives}}</p><p><a href="{{$activate_url}}">{{$activate_url}}</a></p><br>
1313
<p>{{.locale.Tr "mail.link_not_working_do_paste"}}</p>
1414

1515
<p>© <a target="_blank" rel="noopener noreferrer" href="{{AppUrl}}">{{AppName}}</a></p>

templates/mail/auth/activate_email.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
{{$activate_url := printf "%suser/activate_email?code=%s&email=%s" AppUrl (QueryEscape .Code) (QueryEscape .Email)}}
1010
<body>
11-
<p>{{.locale.Tr "mail.hi_user_x" (.DisplayName|DotEscape) | Str2html}}</p><br>
12-
<p>{{.locale.Tr "mail.activate_email.text" .ActiveCodeLives | Str2html}}</p><p><a href="{{$activate_url}}">{{$activate_url}}</a></p><br>
11+
<p>{{.locale.Tr "mail.hi_user_x" (.DisplayName|DotEscape)}}</p><br>
12+
<p>{{.locale.Tr "mail.activate_email.text" .ActiveCodeLives}}</p><p><a href="{{$activate_url}}">{{$activate_url}}</a></p><br>
1313
<p>{{.locale.Tr "mail.link_not_working_do_paste"}}</p>
1414

1515
<p>© <a target="_blank" rel="noopener noreferrer" href="{{AppUrl}}">{{AppName}}</a></p>

templates/mail/auth/register_notify.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
{{$set_pwd_url := printf "%[1]suser/forgot_password" AppUrl}}
1010
<body>
11-
<p>{{.locale.Tr "mail.hi_user_x" (.DisplayName|DotEscape) | Str2html}}</p><br>
11+
<p>{{.locale.Tr "mail.hi_user_x" (.DisplayName|DotEscape)}}</p><br>
1212
<p>{{.locale.Tr "mail.register_notify.text_1" AppName}}</p><br>
1313
<p>{{.locale.Tr "mail.register_notify.text_2" .Username}}</p><p><a href="{{AppUrl}}user/login">{{AppUrl}}user/login</a></p><br>
14-
<p>{{.locale.Tr "mail.register_notify.text_3" ($set_pwd_url | Escape) | Str2html}}</p><br>
14+
<p>{{.locale.Tr "mail.register_notify.text_3" ($set_pwd_url | Escape)}}</p><br>
1515

1616
<p>© <a target="_blank" rel="noopener noreferrer" href="{{AppUrl}}">{{AppName}}</a></p>
1717
</body>

templates/mail/auth/reset_passwd.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
{{$recover_url := printf "%suser/recover_account?code=%s" AppUrl (QueryEscape .Code)}}
1010
<body>
11-
<p>{{.locale.Tr "mail.hi_user_x" (.DisplayName|DotEscape) | Str2html}}</p><br>
12-
<p>{{.locale.Tr "mail.reset_password.text" .ResetPwdCodeLives | Str2html}}</p><p><a href="{{$recover_url}}">{{$recover_url}}</a></p><br>
11+
<p>{{.locale.Tr "mail.hi_user_x" (.DisplayName|DotEscape)}}</p><br>
12+
<p>{{.locale.Tr "mail.reset_password.text" .ResetPwdCodeLives}}</p><p><a href="{{$recover_url}}">{{$recover_url}}</a></p><br>
1313
<p>{{.locale.Tr "mail.link_not_working_do_paste"}}</p>
1414

1515
<p>© <a target="_blank" rel="noopener noreferrer" href="{{AppUrl}}">{{AppName}}</a></p>

templates/mail/issue/default.tmpl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</head>
1717

1818
<body>
19-
{{if .IsMention}}<p>{{.locale.Tr "mail.issue.x_mentioned_you" .Doer.Name | Str2html}}</p>{{end}}
19+
{{if .IsMention}}<p>{{.locale.Tr "mail.issue.x_mentioned_you" .Doer.Name}}</p>{{end}}
2020
{{if eq .ActionName "push"}}
2121
<p>
2222
{{if .Comment.IsForcePush}}
@@ -30,32 +30,32 @@
3030

3131
{{.locale.Tr "mail.issue.action.force_push" .Doer.Name .Comment.Issue.PullRequest.HeadBranch ($oldCommitLink|Safe) ($newCommitLink|Safe)}}
3232
{{else}}
33-
{{.locale.TrN (len .Comment.Commits) "mail.issue.action.push_1" "mail.issue.action.push_n" .Doer.Name .Comment.Issue.PullRequest.HeadBranch (len .Comment.Commits) | Str2html}}
33+
{{.locale.TrN (len .Comment.Commits) "mail.issue.action.push_1" "mail.issue.action.push_n" .Doer.Name .Comment.Issue.PullRequest.HeadBranch (len .Comment.Commits)}}
3434
{{end}}
3535
</p>
3636
{{end}}
3737
<p>
3838
{{if eq .ActionName "close"}}
39-
{{.locale.Tr "mail.issue.action.close" (Escape .Doer.Name) .Issue.Index | Str2html}}
39+
{{.locale.Tr "mail.issue.action.close" (Escape .Doer.Name) .Issue.Index}}
4040
{{else if eq .ActionName "reopen"}}
41-
{{.locale.Tr "mail.issue.action.reopen" (Escape .Doer.Name) .Issue.Index | Str2html}}
41+
{{.locale.Tr "mail.issue.action.reopen" (Escape .Doer.Name) .Issue.Index}}
4242
{{else if eq .ActionName "merge"}}
43-
{{.locale.Tr "mail.issue.action.merge" (Escape .Doer.Name) .Issue.Index (Escape .Issue.PullRequest.BaseBranch) | Str2html}}
43+
{{.locale.Tr "mail.issue.action.merge" (Escape .Doer.Name) .Issue.Index (Escape .Issue.PullRequest.BaseBranch)}}
4444
{{else if eq .ActionName "approve"}}
45-
{{.locale.Tr "mail.issue.action.approve" (Escape .Doer.Name) | Str2html}}
45+
{{.locale.Tr "mail.issue.action.approve" (Escape .Doer.Name)}}
4646
{{else if eq .ActionName "reject"}}
47-
{{.locale.Tr "mail.issue.action.reject" (Escape .Doer.Name) | Str2html}}
47+
{{.locale.Tr "mail.issue.action.reject" (Escape .Doer.Name)}}
4848
{{else if eq .ActionName "review"}}
49-
{{.locale.Tr "mail.issue.action.review" (Escape .Doer.Name) | Str2html}}
49+
{{.locale.Tr "mail.issue.action.review" (Escape .Doer.Name)}}
5050
{{else if eq .ActionName "review_dismissed"}}
51-
{{.locale.Tr "mail.issue.action.review_dismissed" (Escape .Doer.Name) (Escape .Comment.Review.Reviewer.Name) | Str2html}}
51+
{{.locale.Tr "mail.issue.action.review_dismissed" (Escape .Doer.Name) (Escape .Comment.Review.Reviewer.Name)}}
5252
{{else if eq .ActionName "ready_for_review"}}
53-
{{.locale.Tr "mail.issue.action.ready_for_review" (Escape .Doer.Name) | Str2html}}
53+
{{.locale.Tr "mail.issue.action.ready_for_review" (Escape .Doer.Name)}}
5454
{{end}}
5555

5656
{{- if eq .Body ""}}
5757
{{if eq .ActionName "new"}}
58-
{{.locale.Tr "mail.issue.action.new" (Escape .Doer.Name) .Issue.Index | Str2html}}
58+
{{.locale.Tr "mail.issue.action.new" (Escape .Doer.Name) .Issue.Index}}
5959
{{end}}
6060
{{else}}
6161
{{.Body | Str2html}}

templates/mail/team_invite.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta name="format-detection" content="telephone=no,date=no,address=no,email=no,url=no">
66
</head>
77
<body>
8-
<p>{{.locale.Tr "mail.team_invite.text_1" (DotEscape .Inviter.DisplayName) (DotEscape .Team.Name) (DotEscape .Organization.DisplayName) | Str2html}}</p>
8+
<p>{{.locale.Tr "mail.team_invite.text_1" (DotEscape .Inviter.DisplayName) (DotEscape .Team.Name) (DotEscape .Organization.DisplayName)}}</p>
99
<p>{{.locale.Tr "mail.team_invite.text_2"}}</p><p><a href="{{.InviteURL}}">{{.InviteURL}}</a></p>
1010
<p>{{.locale.Tr "mail.link_not_working_do_paste"}}</p>
1111
<p>{{.locale.Tr "mail.team_invite.text_3" .Invite.Email}}</p>

0 commit comments

Comments
 (0)