diff options
Diffstat (limited to 'routers')
-rw-r--r-- | routers/admin/admin.go | 3 | ||||
-rw-r--r-- | routers/api/v1/utils/hook.go | 4 | ||||
-rw-r--r-- | routers/events/events.go | 3 | ||||
-rw-r--r-- | routers/private/mail.go | 3 | ||||
-rw-r--r-- | routers/private/manager.go | 3 | ||||
-rw-r--r-- | routers/repo/editor.go | 3 | ||||
-rw-r--r-- | routers/repo/webhook.go | 10 | ||||
-rw-r--r-- | routers/user/home.go | 3 |
8 files changed, 24 insertions, 8 deletions
diff --git a/routers/admin/admin.go b/routers/admin/admin.go index 2b2328a93a..49f6a394a6 100644 --- a/routers/admin/admin.go +++ b/routers/admin/admin.go @@ -6,7 +6,6 @@ package admin import ( - "encoding/json" "fmt" "net/url" "os" @@ -28,6 +27,7 @@ import ( "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/web" "code.gitea.io/gitea/services/mailer" + jsoniter "github.com/json-iterator/go" "gitea.com/go-chi/session" ) @@ -274,6 +274,7 @@ func Config(ctx *context.Context) { sessionCfg := setting.SessionConfig if sessionCfg.Provider == "VirtualSession" { var realSession session.Options + json := jsoniter.ConfigCompatibleWithStandardLibrary if err := json.Unmarshal([]byte(sessionCfg.ProviderConfig), &realSession); err != nil { log.Error("Unable to unmarshall session config for virtualed provider config: %s\nError: %v", sessionCfg.ProviderConfig, err) } diff --git a/routers/api/v1/utils/hook.go b/routers/api/v1/utils/hook.go index b0ce40b9fb..c7af40dcf0 100644 --- a/routers/api/v1/utils/hook.go +++ b/routers/api/v1/utils/hook.go @@ -5,7 +5,6 @@ package utils import ( - "encoding/json" "fmt" "net/http" "strings" @@ -17,6 +16,7 @@ import ( "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/routers/utils" "code.gitea.io/gitea/services/webhook" + jsoniter "github.com/json-iterator/go" ) // GetOrgHook get an organization's webhook. If there is an error, write to @@ -147,6 +147,7 @@ func addHook(ctx *context.APIContext, form *api.CreateHookOption, orgID, repoID return nil, false } + json := jsoniter.ConfigCompatibleWithStandardLibrary meta, err := json.Marshal(&webhook.SlackMeta{ Channel: strings.TrimSpace(channel), Username: form.Config["username"], @@ -221,6 +222,7 @@ func editHook(ctx *context.APIContext, form *api.EditHookOption, w *models.Webho if w.Type == models.SLACK { if channel, ok := form.Config["channel"]; ok { + json := jsoniter.ConfigCompatibleWithStandardLibrary meta, err := json.Marshal(&webhook.SlackMeta{ Channel: channel, Username: form.Config["username"], diff --git a/routers/events/events.go b/routers/events/events.go index 2b78d8603b..27dbb08fc8 100644 --- a/routers/events/events.go +++ b/routers/events/events.go @@ -5,7 +5,6 @@ package events import ( - "encoding/json" "net/http" "time" @@ -17,6 +16,7 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/routers/user" + jsoniter "github.com/json-iterator/go" ) // Events listens for events @@ -92,6 +92,7 @@ loop: log.Error("Unable to APIFormat stopwatches: %v", err) continue } + json := jsoniter.ConfigCompatibleWithStandardLibrary dataBs, err := json.Marshal(apiSWs) if err != nil { log.Error("Unable to marshal stopwatches: %v", err) diff --git a/routers/private/mail.go b/routers/private/mail.go index 330de14c46..cda442ea04 100644 --- a/routers/private/mail.go +++ b/routers/private/mail.go @@ -5,7 +5,6 @@ package private import ( - "encoding/json" "fmt" "net/http" "strconv" @@ -16,6 +15,7 @@ import ( "code.gitea.io/gitea/modules/private" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/services/mailer" + jsoniter "github.com/json-iterator/go" ) // SendEmail pushes messages to mail queue @@ -32,6 +32,7 @@ func SendEmail(ctx *context.PrivateContext) { var mail private.Email rd := ctx.Req.Body defer rd.Close() + json := jsoniter.ConfigCompatibleWithStandardLibrary if err := json.NewDecoder(rd).Decode(&mail); err != nil { log.Error("%v", err) ctx.JSON(http.StatusInternalServerError, map[string]interface{}{ diff --git a/routers/private/manager.go b/routers/private/manager.go index e5b4583fd1..192c4947e7 100644 --- a/routers/private/manager.go +++ b/routers/private/manager.go @@ -5,7 +5,6 @@ package private import ( - "encoding/json" "fmt" "net/http" @@ -16,6 +15,7 @@ import ( "code.gitea.io/gitea/modules/queue" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/web" + jsoniter "github.com/json-iterator/go" ) // FlushQueues flushes all the Queues @@ -130,6 +130,7 @@ func AddLogger(ctx *context.PrivateContext) { } bufferLen := setting.Cfg.Section("log").Key("BUFFER_LEN").MustInt64(10000) + json := jsoniter.ConfigCompatibleWithStandardLibrary byteConfig, err := json.Marshal(opts.Config) if err != nil { log.Error("Failed to marshal log configuration: %v %v", opts.Config, err) diff --git a/routers/repo/editor.go b/routers/repo/editor.go index 344174828e..14a75556d2 100644 --- a/routers/repo/editor.go +++ b/routers/repo/editor.go @@ -5,7 +5,6 @@ package repo import ( - "encoding/json" "fmt" "io/ioutil" "path" @@ -25,6 +24,7 @@ import ( "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/modules/web" "code.gitea.io/gitea/routers/utils" + jsoniter "github.com/json-iterator/go" ) const ( @@ -158,6 +158,7 @@ func GetEditorConfig(ctx *context.Context, treePath string) string { if err == nil { def, err := ec.GetDefinitionForFilename(treePath) if err == nil { + json := jsoniter.ConfigCompatibleWithStandardLibrary jsonStr, _ := json.Marshal(def) return string(jsonStr) } diff --git a/routers/repo/webhook.go b/routers/repo/webhook.go index 01d142843f..d1d4dc0208 100644 --- a/routers/repo/webhook.go +++ b/routers/repo/webhook.go @@ -6,7 +6,6 @@ package repo import ( - "encoding/json" "errors" "fmt" "path" @@ -23,6 +22,7 @@ import ( "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/modules/web" "code.gitea.io/gitea/services/webhook" + jsoniter "github.com/json-iterator/go" ) const ( @@ -305,6 +305,7 @@ func DiscordHooksNewPost(ctx *context.Context) { return } + json := jsoniter.ConfigCompatibleWithStandardLibrary meta, err := json.Marshal(&webhook.DiscordMeta{ Username: form.Username, IconURL: form.IconURL, @@ -400,6 +401,7 @@ func TelegramHooksNewPost(ctx *context.Context) { return } + json := jsoniter.ConfigCompatibleWithStandardLibrary meta, err := json.Marshal(&webhook.TelegramMeta{ BotToken: form.BotToken, ChatID: form.ChatID, @@ -452,6 +454,7 @@ func MatrixHooksNewPost(ctx *context.Context) { return } + json := jsoniter.ConfigCompatibleWithStandardLibrary meta, err := json.Marshal(&webhook.MatrixMeta{ HomeserverURL: form.HomeserverURL, Room: form.RoomID, @@ -556,6 +559,7 @@ func SlackHooksNewPost(ctx *context.Context) { return } + json := jsoniter.ConfigCompatibleWithStandardLibrary meta, err := json.Marshal(&webhook.SlackMeta{ Channel: strings.TrimSpace(form.Channel), Username: form.Username, @@ -799,6 +803,7 @@ func SlackHooksEditPost(ctx *context.Context) { return } + json := jsoniter.ConfigCompatibleWithStandardLibrary meta, err := json.Marshal(&webhook.SlackMeta{ Channel: strings.TrimSpace(form.Channel), Username: form.Username, @@ -844,6 +849,7 @@ func DiscordHooksEditPost(ctx *context.Context) { return } + json := jsoniter.ConfigCompatibleWithStandardLibrary meta, err := json.Marshal(&webhook.DiscordMeta{ Username: form.Username, IconURL: form.IconURL, @@ -919,6 +925,7 @@ func TelegramHooksEditPost(ctx *context.Context) { ctx.HTML(200, orCtx.NewTemplate) return } + json := jsoniter.ConfigCompatibleWithStandardLibrary meta, err := json.Marshal(&webhook.TelegramMeta{ BotToken: form.BotToken, ChatID: form.ChatID, @@ -960,6 +967,7 @@ func MatrixHooksEditPost(ctx *context.Context) { ctx.HTML(200, orCtx.NewTemplate) return } + json := jsoniter.ConfigCompatibleWithStandardLibrary meta, err := json.Marshal(&webhook.MatrixMeta{ HomeserverURL: form.HomeserverURL, Room: form.RoomID, diff --git a/routers/user/home.go b/routers/user/home.go index a8020b64e0..9957ec6b02 100644 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -7,7 +7,6 @@ package user import ( "bytes" - "encoding/json" "fmt" "regexp" "sort" @@ -25,6 +24,7 @@ import ( issue_service "code.gitea.io/gitea/services/issue" pull_service "code.gitea.io/gitea/services/pull" + jsoniter "github.com/json-iterator/go" "github.com/keybase/go-crypto/openpgp" "github.com/keybase/go-crypto/openpgp/armor" "xorm.io/builder" @@ -691,6 +691,7 @@ func buildIssueOverview(ctx *context.Context, unitType models.UnitType) { } // Convert []int64 to string + json := jsoniter.ConfigCompatibleWithStandardLibrary reposParam, _ := json.Marshal(repoIDs) ctx.Data["ReposParam"] = string(reposParam) |