diff options
Diffstat (limited to 'modules/templates/helper.go')
-rw-r--r-- | modules/templates/helper.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 4b9b648b2f..d3f6b8e06f 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -38,6 +38,7 @@ import ( mirror_service "code.gitea.io/gitea/services/mirror" "github.com/editorconfig/editorconfig-core-go/v2" + jsoniter "github.com/json-iterator/go" ) // Used from static.go && dynamic.go @@ -45,6 +46,7 @@ var mailSubjectSplit = regexp.MustCompile(`(?m)^-{3,}[\s]*$`) // NewFuncMap returns functions for injecting to templates func NewFuncMap() []template.FuncMap { + jsonED := jsoniter.ConfigCompatibleWithStandardLibrary return []template.FuncMap{map[string]interface{}{ "GoVer": func() string { return strings.Title(runtime.Version()) @@ -215,7 +217,7 @@ func NewFuncMap() []template.FuncMap { return fmt.Sprintf("%f", float64(adds)/(float64(adds)+float64(dels))*100) }, "Json": func(in interface{}) string { - out, err := json.Marshal(in) + out, err := jsonED.Marshal(in) if err != nil { return "" } @@ -814,6 +816,8 @@ func ActionIcon(opType models.ActionType) string { // ActionContent2Commits converts action content to push commits func ActionContent2Commits(act Actioner) *repository.PushCommits { push := repository.NewPushCommits() + + json := jsoniter.ConfigCompatibleWithStandardLibrary if err := json.Unmarshal([]byte(act.GetContent()), push); err != nil { log.Error("json.Unmarshal:\n%s\nERROR: %v", act.GetContent(), err) } |