1
0
Fork 0
forked from forgejo/forgejo

Refactor Safe modifier (#29392)

After this PR: no need to play with the Safe/Escape tricks anymore. See
the changes for more details.

(cherry picked from commit f9207b09479df964872d68842469991042b5497f)

Conflicts:
	templates/repo/issue/view_title.tmpl
	templates/user/settings/applications.tmpl
	context
This commit is contained in:
wxiaoguang 2024-02-25 18:45:56 +08:00 committed by Earl Warren
parent 30fe3d8d4c
commit 90a62b87c0
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
24 changed files with 79 additions and 55 deletions

View file

@ -4,6 +4,7 @@
package templates
import (
"html/template"
"testing"
"github.com/stretchr/testify/assert"
@ -56,3 +57,7 @@ func TestSubjectBodySeparator(t *testing.T) {
func TestJSEscapeSafe(t *testing.T) {
assert.EqualValues(t, `\u0026\u003C\u003E\'\"`, JSEscapeSafe(`&<>'"`))
}
func TestHTMLFormat(t *testing.T) {
assert.Equal(t, template.HTML("<a>&lt; < 1</a>"), HTMLFormat("<a>%s %s %d</a>", "<", template.HTML("<"), 1))
}