diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2024-02-18 17:52:02 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-18 10:52:02 +0100 |
commit | 31bb9f3247388b993c61a10190cfd512408ce57e (patch) | |
tree | 6a4c777d5507b8e92cebd1786750c6a4db9367c8 /modules/templates/helper_test.go | |
parent | a784ed3d6c6946fd9bf95f2e910f52f549326fe2 (diff) | |
download | gitea-31bb9f3247388b993c61a10190cfd512408ce57e.tar.gz gitea-31bb9f3247388b993c61a10190cfd512408ce57e.zip |
Refactor more code in templates (#29236)
Follow #29165.
* Introduce JSONTemplate to help to render JSON templates
* Introduce JSEscapeSafe for templates. Now only use `{{ ... |
JSEscape}}` instead of `{{ ... | JSEscape | Safe}}`
* Simplify "UserLocationMapURL" useage
Diffstat (limited to 'modules/templates/helper_test.go')
-rw-r--r-- | modules/templates/helper_test.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/modules/templates/helper_test.go b/modules/templates/helper_test.go index ec83e9ac33..739a92f34f 100644 --- a/modules/templates/helper_test.go +++ b/modules/templates/helper_test.go @@ -52,3 +52,7 @@ func TestSubjectBodySeparator(t *testing.T) { "", "Insuficient\n--\nSeparators") } + +func TestJSEscapeSafe(t *testing.T) { + assert.EqualValues(t, `\u0026\u003C\u003E\'\"`, JSEscapeSafe(`&<>'"`)) +} |