From 0f72cd850880632824b7701366f98cb2e54f794f Mon Sep 17 00:00:00 2001 From: Gusted Date: Tue, 16 Apr 2024 12:37:32 +0200 Subject: [PATCH] [BUG] Escape editor.add_tmpl translation - Previously translations were escaped, but now translations are accepted as-is and will be rendered as HTML. Use `TrString` to escape the translation value. - Adds integration test. - Regression of 65248945c9b7bc54d41e7b7dcc5df42b51b3bcd6. - Resolves #3260 (cherry picked from commit a0f47b8de702051ae80239ae395a5a3c5a4c84d0) --- templates/repo/editor/commit_form.tmpl | 2 +- tests/integration/editor_test.go | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/templates/repo/editor/commit_form.tmpl b/templates/repo/editor/commit_form.tmpl index b2fe5b1cfb..9f81b1d3a0 100644 --- a/templates/repo/editor/commit_form.tmpl +++ b/templates/repo/editor/commit_form.tmpl @@ -9,7 +9,7 @@ {{ctx.Locale.Tr "repo.editor.commit_changes"}} {{- end}}
- +
diff --git a/tests/integration/editor_test.go b/tests/integration/editor_test.go index f2f312b8a4..3e8416925b 100644 --- a/tests/integration/editor_test.go +++ b/tests/integration/editor_test.go @@ -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 ""`, placeholder) +} + func TestCommitMail(t *testing.T) { onGiteaRun(t, func(t *testing.T, _ *url.URL) { user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})