Merge pull request '[v7.0/forgejo] [BUG] Escape editor.add_tmpl translation' (#3272) from bp-v7.0/forgejo-a0f47b8 into v7.0/forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3272
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
This commit is contained in:
0ko 2024-04-16 18:04:47 +00:00
commit 515d71bffa
2 changed files with 14 additions and 1 deletions

View file

@ -9,7 +9,7 @@
{{ctx.Locale.Tr "repo.editor.commit_changes"}}
{{- end}}</h3>
<div class="field">
<input name="commit_summary" maxlength="100" placeholder="{{if .PageIsDelete}}{{ctx.Locale.Tr "repo.editor.delete" .TreePath}}{{else if .PageIsUpload}}{{ctx.Locale.Tr "repo.editor.upload_files_to_dir" .TreePath}}{{else if .IsNewFile}}{{ctx.Locale.Tr "repo.editor.add_tmpl"}}{{else if .PageIsPatch}}{{ctx.Locale.Tr "repo.editor.patch"}}{{else}}{{ctx.Locale.Tr "repo.editor.update" .TreePath}}{{end}}" value="{{.commit_summary}}" autofocus>
<input name="commit_summary" maxlength="100" placeholder="{{if .PageIsDelete}}{{ctx.Locale.Tr "repo.editor.delete" .TreePath}}{{else if .PageIsUpload}}{{ctx.Locale.Tr "repo.editor.upload_files_to_dir" .TreePath}}{{else if .IsNewFile}}{{ctx.Locale.TrString "repo.editor.add_tmpl"}}{{else if .PageIsPatch}}{{ctx.Locale.Tr "repo.editor.patch"}}{{else}}{{ctx.Locale.Tr "repo.editor.update" .TreePath}}{{end}}" value="{{.commit_summary}}" autofocus>
</div>
<div class="field">
<textarea name="commit_message" placeholder="{{ctx.Locale.Tr "repo.editor.commit_message_desc"}}" rows="5">{{.commit_message}}</textarea>

View file

@ -187,6 +187,19 @@ func TestEditFileToNewBranch(t *testing.T) {
})
}
func TestEditorAddTranslation(t *testing.T) {
defer tests.PrepareTestEnv(t)()
session := loginUser(t, "user2")
req := NewRequest(t, "GET", "/user2/repo1/_new/master")
resp := session.MakeRequest(t, req, http.StatusOK)
htmlDoc := NewHTMLParser(t, resp.Body)
placeholder, ok := htmlDoc.Find("input[name='commit_summary']").Attr("placeholder")
assert.True(t, ok)
assert.EqualValues(t, `Add "<filename>"`, placeholder)
}
func TestCommitMail(t *testing.T) {
onGiteaRun(t, func(t *testing.T, _ *url.URL) {
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})