package main
import (
- "encoding/json"
"flag"
"fmt"
"go/format"
"strconv"
"strings"
"unicode/utf8"
+
+ jsoniter "github.com/json-iterator/go"
)
const (
x.UnicodeVersion = ""
x.Description = ""
x.SkinTones = false
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Marshal(x)
}
// unmarshal
var data Gemoji
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
err = json.Unmarshal(body, &data)
if err != nil {
return nil, err
package cmd
import (
- "encoding/json"
"fmt"
"io/ioutil"
"os"
"code.gitea.io/gitea/modules/util"
"gitea.com/go-chi/session"
+ jsoniter "github.com/json-iterator/go"
archiver "github.com/mholt/archiver/v3"
"github.com/urfave/cli"
)
var excludes []string
if setting.Cfg.Section("session").Key("PROVIDER").Value() == "file" {
var opts session.Options
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
if err = json.Unmarshal([]byte(setting.SessionConfig.ProviderConfig), &opts); err != nil {
return err
}
package cmd
import (
- "encoding/json"
"fmt"
"net/http"
"net/url"
"code.gitea.io/gitea/modules/setting"
"github.com/dgrijalva/jwt-go"
+ jsoniter "github.com/json-iterator/go"
"github.com/kballard/go-shellquote"
"github.com/urfave/cli"
)
}
tokenAuthentication.Header["Authorization"] = fmt.Sprintf("Bearer %s", tokenString)
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
enc := json.NewEncoder(os.Stdout)
err = enc.Encode(tokenAuthentication)
if err != nil {
cloud.google.com/go v0.78.0 // indirect
code.gitea.io/gitea-vet v0.2.1
code.gitea.io/sdk/gitea v0.13.2
- gitea.com/go-chi/binding v0.0.0-20210113025129-03f1d313373c
+ gitea.com/go-chi/binding v0.0.0-20210301195521-1fe1c9a555e7
gitea.com/go-chi/cache v0.0.0-20210110083709-82c4c9ce2d5e
gitea.com/go-chi/captcha v0.0.0-20210110083842-e7696c336a1e
gitea.com/go-chi/session v0.0.0-20210108030337-0cb48c5ba8ee
github.com/issue9/assert v1.3.2 // indirect
github.com/issue9/identicon v1.0.1
github.com/jaytaylor/html2text v0.0.0-20200412013138-3577fbdbcff7
+ github.com/json-iterator/go v1.1.10
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect
github.com/keybase/go-crypto v0.0.0-20200123153347-de78d2cb44f4
code.gitea.io/sdk/gitea v0.13.2 h1:wAnT/J7Z62q3fJXbgnecoaOBh8CM1Qq0/DakWxiv4yA=
code.gitea.io/sdk/gitea v0.13.2/go.mod h1:lee2y8LeV3kQb2iK+hHlMqoadL4bp27QOkOV/hawLKg=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
-gitea.com/go-chi/binding v0.0.0-20210113025129-03f1d313373c h1:NTtrGYjR40WUdkCdn26Y5LGFT52rIkFPkjmtgCAyiTs=
-gitea.com/go-chi/binding v0.0.0-20210113025129-03f1d313373c/go.mod h1:9bGA9dIsrz+wVQKH1DzvxuAvrudHaQ8Wx8hLme/GVGQ=
+gitea.com/go-chi/binding v0.0.0-20210301195521-1fe1c9a555e7 h1:xCVJPY823C8RWpgMabTw2kOglDrg0iS3GcQU6wdwHkU=
+gitea.com/go-chi/binding v0.0.0-20210301195521-1fe1c9a555e7/go.mod h1:AyfTrwtfYN54R/HmVvMYPnSTenH5bVoyh8x6tBluxEA=
gitea.com/go-chi/cache v0.0.0-20210110083709-82c4c9ce2d5e h1:zgPGaf3kXP0cVm9J0l8ZA2+XDzILYATg0CXbihR6N+o=
gitea.com/go-chi/cache v0.0.0-20210110083709-82c4c9ce2d5e/go.mod h1:k2V/gPDEtXGjjMGuBJiapffAXTv76H4snSmlJRLUhH0=
gitea.com/go-chi/captcha v0.0.0-20210110083842-e7696c336a1e h1:YjaQU6XFicdhPN+MlGolcXO8seYY2+EY5g7vZPB17CQ=
package integrations
import (
- "encoding/json"
"fmt"
"net/http"
"testing"
"code.gitea.io/gitea/models"
api "code.gitea.io/gitea/modules/structs"
+ jsoniter "github.com/json-iterator/go"
"github.com/stretchr/testify/assert"
)
resp := session.MakeRequest(t, req, http.StatusUnprocessableEntity)
errMap := make(map[string]interface{})
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
json.Unmarshal(resp.Body.Bytes(), &errMap)
assert.EqualValues(t, "email is not allowed to be empty string", errMap["message"].(string))
import (
"context"
- "encoding/json"
"fmt"
"io/ioutil"
"net/http"
"code.gitea.io/gitea/modules/queue"
api "code.gitea.io/gitea/modules/structs"
+ jsoniter "github.com/json-iterator/go"
"github.com/stretchr/testify/assert"
)
expected = ctx.ExpectedCode
}
resp := ctx.Session.MakeRequest(t, req, expected)
+
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
decoder := json.NewDecoder(resp.Body)
pr := api.PullRequest{}
err := decoder.Decode(&pr)
package integrations
import (
- "encoding/json"
"io/ioutil"
"net/http"
"net/http/httptest"
"code.gitea.io/gitea/routers/routes"
"gitea.com/go-chi/session"
+ jsoniter "github.com/json-iterator/go"
"github.com/stretchr/testify/assert"
)
}()
var config session.Options
+
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
err := json.Unmarshal([]byte(oldSessionConfig), &config)
assert.NoError(t, err)
"bytes"
"context"
"database/sql"
- "encoding/json"
"fmt"
"io"
"net/http"
"code.gitea.io/gitea/routers/routes"
"github.com/PuerkitoBio/goquery"
+ jsoniter "github.com/json-iterator/go"
"github.com/stretchr/testify/assert"
)
func NewRequestWithJSON(t testing.TB, method, urlStr string, v interface{}) *http.Request {
t.Helper()
+
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
jsonBytes, err := json.Marshal(v)
assert.NoError(t, err)
req := NewRequestWithBody(t, method, urlStr, bytes.NewBuffer(jsonBytes))
func DecodeJSON(t testing.TB, resp *httptest.ResponseRecorder, v interface{}) {
t.Helper()
+
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
decoder := json.NewDecoder(resp.Body)
assert.NoError(t, decoder.Decode(v))
}
import (
"bytes"
- "encoding/json"
"io/ioutil"
"testing"
"code.gitea.io/gitea/modules/setting"
+ jsoniter "github.com/json-iterator/go"
"github.com/stretchr/testify/assert"
)
RefreshToken string `json:"refresh_token"`
}
parsed := new(response)
+
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
assert.NoError(t, json.Unmarshal(resp.Body.Bytes(), parsed))
assert.True(t, len(parsed.AccessToken) > 10)
assert.True(t, len(parsed.RefreshToken) > 10)
RefreshToken string `json:"refresh_token"`
}
parsed := new(response)
+
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
assert.NoError(t, json.Unmarshal(resp.Body.Bytes(), parsed))
assert.True(t, len(parsed.AccessToken) > 10)
assert.True(t, len(parsed.RefreshToken) > 10)
RefreshToken string `json:"refresh_token"`
}
parsed := new(response)
+
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
assert.NoError(t, json.Unmarshal(resp.Body.Bytes(), parsed))
assert.True(t, len(parsed.AccessToken) > 10)
assert.True(t, len(parsed.RefreshToken) > 10)
RefreshToken string `json:"refresh_token"`
}
parsed := new(response)
+
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
assert.NoError(t, json.Unmarshal(resp.Body.Bytes(), parsed))
// test without invalidation
package integrations
import (
- "encoding/json"
"net/http"
"net/http/httptest"
"path"
"code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
+ jsoniter "github.com/json-iterator/go"
"github.com/stretchr/testify/assert"
)
}
func testRepoCommitsWithStatus(t *testing.T, resp *httptest.ResponseRecorder, state string) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
decoder := json.NewDecoder(resp.Body)
statuses := []*api.CommitStatus{}
assert.NoError(t, decoder.Decode(&statuses))
import (
"context"
- "encoding/json"
"fmt"
"os"
"runtime"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/queue"
+ jsoniter "github.com/json-iterator/go"
)
var (
// Init inits connection writer with json config.
// json config only need key "level".
func (log *TestLogger) Init(config string) error {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
err := json.Unmarshal([]byte(config), log)
if err != nil {
return err
import (
"container/list"
- "encoding/json"
"fmt"
"regexp"
"strconv"
"code.gitea.io/gitea/modules/references"
"code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/timeutil"
+ jsoniter "github.com/json-iterator/go"
"xorm.io/builder"
"xorm.io/xorm"
var data PushActionContent
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
err = json.Unmarshal([]byte(c.Content), &data)
if err != nil {
return
}
ops.Issue = pr.Issue
+
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
dataJSON, err := json.Marshal(data)
if err != nil {
return nil, err
import (
"crypto/tls"
- "encoding/json"
"errors"
"fmt"
"net/smtp"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/util"
+ jsoniter "github.com/json-iterator/go"
"xorm.io/xorm"
"xorm.io/xorm/convert"
// FromDB fills up a LDAPConfig from serialized format.
func (cfg *LDAPConfig) FromDB(bs []byte) error {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Unmarshal(bs, &cfg)
}
// ToDB exports a LDAPConfig to a serialized format.
func (cfg *LDAPConfig) ToDB() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Marshal(cfg)
}
// FromDB fills up an SMTPConfig from serialized format.
func (cfg *SMTPConfig) FromDB(bs []byte) error {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Unmarshal(bs, cfg)
}
// ToDB exports an SMTPConfig to a serialized format.
func (cfg *SMTPConfig) ToDB() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Marshal(cfg)
}
// FromDB fills up a PAMConfig from serialized format.
func (cfg *PAMConfig) FromDB(bs []byte) error {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Unmarshal(bs, &cfg)
}
// ToDB exports a PAMConfig to a serialized format.
func (cfg *PAMConfig) ToDB() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Marshal(cfg)
}
// FromDB fills up an OAuth2Config from serialized format.
func (cfg *OAuth2Config) FromDB(bs []byte) error {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Unmarshal(bs, cfg)
}
// ToDB exports an SMTPConfig to a serialized format.
func (cfg *OAuth2Config) ToDB() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Marshal(cfg)
}
// FromDB fills up an SSPIConfig from serialized format.
func (cfg *SSPIConfig) FromDB(bs []byte) error {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Unmarshal(bs, cfg)
}
// ToDB exports an SSPIConfig to a serialized format.
func (cfg *SSPIConfig) ToDB() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Marshal(cfg)
}
package migrations
import (
- "encoding/json"
-
"code.gitea.io/gitea/modules/setting"
+ jsoniter "github.com/json-iterator/go"
"xorm.io/xorm"
)
for _, res := range results {
var events HookEvent
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
if err = json.Unmarshal([]byte(res.Events), &events); err != nil {
return err
}
package models
import (
- "encoding/json"
"fmt"
"code.gitea.io/gitea/modules/timeutil"
+ jsoniter "github.com/json-iterator/go"
"xorm.io/xorm"
"xorm.io/xorm/convert"
)
// FromDB fills up a UnitConfig from serialized format.
func (cfg *UnitConfig) FromDB(bs []byte) error {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Unmarshal(bs, &cfg)
}
// ToDB exports a UnitConfig to a serialized format.
func (cfg *UnitConfig) ToDB() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Marshal(cfg)
}
// FromDB fills up a ExternalWikiConfig from serialized format.
func (cfg *ExternalWikiConfig) FromDB(bs []byte) error {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Unmarshal(bs, &cfg)
}
// ToDB exports a ExternalWikiConfig to a serialized format.
func (cfg *ExternalWikiConfig) ToDB() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Marshal(cfg)
}
// FromDB fills up a ExternalTrackerConfig from serialized format.
func (cfg *ExternalTrackerConfig) FromDB(bs []byte) error {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Unmarshal(bs, &cfg)
}
// ToDB exports a ExternalTrackerConfig to a serialized format.
func (cfg *ExternalTrackerConfig) ToDB() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Marshal(cfg)
}
// FromDB fills up a IssuesConfig from serialized format.
func (cfg *IssuesConfig) FromDB(bs []byte) error {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Unmarshal(bs, &cfg)
}
// ToDB exports a IssuesConfig to a serialized format.
func (cfg *IssuesConfig) ToDB() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Marshal(cfg)
}
// FromDB fills up a PullRequestsConfig from serialized format.
func (cfg *PullRequestsConfig) FromDB(bs []byte) error {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Unmarshal(bs, &cfg)
}
// ToDB exports a PullRequestsConfig to a serialized format.
func (cfg *PullRequestsConfig) ToDB() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Marshal(cfg)
}
package models
import (
- "encoding/json"
"fmt"
migration "code.gitea.io/gitea/modules/migrations/base"
"code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/timeutil"
+ jsoniter "github.com/json-iterator/go"
"xorm.io/builder"
)
func (task *Task) MigrateConfig() (*migration.MigrateOptions, error) {
if task.Type == structs.TaskTypeMigrateRepo {
var opts migration.MigrateOptions
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
err := json.Unmarshal([]byte(task.PayloadContent), &opts)
if err != nil {
return nil, err
}
var opts migration.MigrateOptions
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
if err := json.Unmarshal([]byte(task.PayloadContent), &opts); err != nil {
return nil, nil, err
}
package models
import (
- "encoding/json"
"fmt"
"testing"
+ jsoniter "github.com/json-iterator/go"
"github.com/stretchr/testify/assert"
)
assert.Equal(t, tc.CountResult, len(heatmap), fmt.Sprintf("testcase %d", i))
//Test JSON rendering
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
jsonData, err := json.Marshal(heatmap)
assert.NoError(t, err)
assert.Equal(t, tc.JSONResult, string(jsonData))
import (
"context"
- "encoding/json"
"fmt"
"strings"
"time"
"code.gitea.io/gitea/modules/timeutil"
gouuid "github.com/google/uuid"
+ jsoniter "github.com/json-iterator/go"
)
// HookContentType is the content type of a web hook
// AfterLoad updates the webhook object upon setting a column
func (w *Webhook) AfterLoad() {
w.HookEvent = &HookEvent{}
+
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
if err := json.Unmarshal([]byte(w.Events), w.HookEvent); err != nil {
log.Error("Unmarshal[%d]: %v", w.ID, err)
}
// UpdateEvent handles conversion from HookEvent to Events.
func (w *Webhook) UpdateEvent() error {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
data, err := json.Marshal(w.HookEvent)
w.Events = string(data)
return err
}
t.RequestInfo = &HookRequest{}
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
if err := json.Unmarshal([]byte(t.RequestContent), t.RequestInfo); err != nil {
log.Error("Unmarshal RequestContent[%d]: %v", t.ID, err)
}
}
func (t *HookTask) simpleMarshalJSON(v interface{}) string {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
p, err := json.Marshal(v)
if err != nil {
log.Error("Marshal [%d]: %v", t.ID, err)
import (
"context"
- "encoding/json"
"testing"
"time"
api "code.gitea.io/gitea/modules/structs"
+ jsoniter "github.com/json-iterator/go"
"github.com/stretchr/testify/assert"
)
assert.NoError(t, webhook.UpdateEvent())
assert.NotEmpty(t, webhook.Events)
actualHookEvent := &HookEvent{}
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
assert.NoError(t, json.Unmarshal([]byte(webhook.Events), actualHookEvent))
assert.Equal(t, *hookEvent, *actualHookEvent)
}
"context"
"crypto/sha256"
"encoding/hex"
- "encoding/json"
"fmt"
"html"
"html/template"
"gitea.com/go-chi/cache"
"gitea.com/go-chi/session"
"github.com/go-chi/chi"
+ jsoniter "github.com/json-iterator/go"
"github.com/unknwon/com"
"github.com/unknwon/i18n"
"github.com/unrolled/render"
func (ctx *Context) JSON(status int, content interface{}) {
ctx.Resp.Header().Set("Content-Type", "application/json;charset=utf-8")
ctx.Resp.WriteHeader(status)
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
if err := json.NewEncoder(ctx.Resp).Encode(content); err != nil {
ctx.ServerError("Render JSON failed", err)
}
import (
"bytes"
- "encoding/json"
"fmt"
"io"
"strings"
"time"
+
+ jsoniter "github.com/json-iterator/go"
)
func wrapNewlines(w io.Writer, prefix []byte, value []byte) (sum int64, err error) {
data = []byte(v)
default:
var err error
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
data, err = json.Marshal(e.Data)
if err != nil {
return sum, err
import (
"bytes"
"crypto/tls"
- "encoding/json"
"encoding/xml"
"io"
"io/ioutil"
"strings"
"sync"
"time"
+
+ jsoniter "github.com/json-iterator/go"
)
var defaultSetting = Settings{false, "GiteaServer", 60 * time.Second, 60 * time.Second, nil, nil, nil, false}
if err != nil {
return err
}
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
err = json.Unmarshal(data, v)
return err
}
import (
"context"
- "encoding/json"
"fmt"
"strconv"
"strings"
"code.gitea.io/gitea/modules/timeutil"
"github.com/go-enry/go-enry/v2"
+ jsoniter "github.com/json-iterator/go"
"github.com/olivere/elastic/v7"
)
repoID, fileName := parseIndexerID(hit.Id)
var res = make(map[string]interface{})
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
if err := json.Unmarshal(hit.Source, &res); err != nil {
return 0, nil, nil, err
}
package lfs
import (
- "encoding/json"
"strconv"
"strings"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
+ jsoniter "github.com/json-iterator/go"
)
//checkIsValidRequest check if it a valid request in case of bad request it write the response to ctx.
var req api.LFSLockRequest
bodyReader := ctx.Req.Body
defer bodyReader.Close()
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
dec := json.NewDecoder(bodyReader)
if err := dec.Decode(&req); err != nil {
log.Warn("Failed to decode lock request as json. Error: %v", err)
var req api.LFSLockDeleteRequest
bodyReader := ctx.Req.Body
defer bodyReader.Close()
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
dec := json.NewDecoder(bodyReader)
if err := dec.Decode(&req); err != nil {
log.Warn("Failed to decode lock request as json. Error: %v", err)
import (
"encoding/base64"
- "encoding/json"
"fmt"
"io"
"net/http"
"code.gitea.io/gitea/modules/storage"
"github.com/dgrijalva/jwt-go"
+ jsoniter "github.com/json-iterator/go"
)
const (
ctx.Resp.Header().Set("Content-Type", metaMediaType)
if ctx.Req.Method == "GET" {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
enc := json.NewEncoder(ctx.Resp)
if err := enc.Encode(Represent(rv, meta, true, false)); err != nil {
log.Error("Failed to encode representation as json. Error: %v", err)
}
ctx.Resp.WriteHeader(sentStatus)
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
enc := json.NewEncoder(ctx.Resp)
if err := enc.Encode(Represent(rv, meta, meta.Existing, true)); err != nil {
log.Error("Failed to encode representation as json. Error: %v", err)
respobj := &BatchResponse{Objects: responseObjects}
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
enc := json.NewEncoder(ctx.Resp)
if err := enc.Encode(respobj); err != nil {
log.Error("Failed to encode representation as json. Error: %v", err)
var p RequestVars
bodyReader := r.Body
defer bodyReader.Close()
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
dec := json.NewDecoder(bodyReader)
err := dec.Decode(&p)
if err != nil {
bodyReader := r.Body
defer bodyReader.Close()
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
dec := json.NewDecoder(bodyReader)
err := dec.Decode(&bv)
if err != nil {
package log
import (
- "encoding/json"
+ "fmt"
"io"
"net"
+
+ jsoniter "github.com/json-iterator/go"
)
type connWriter struct {
// Init inits connection writer with json config.
// json config only need key "level".
func (log *ConnLogger) Init(jsonconfig string) error {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
err := json.Unmarshal([]byte(jsonconfig), log)
if err != nil {
- return err
+ return fmt.Errorf("Unable to parse JSON: %v", err)
}
log.NewWriterLogger(&connWriter{
ReconnectOnMsg: log.ReconnectOnMsg,
logger := NewConn()
err := logger.Init("{")
- assert.Equal(t, "unexpected end of JSON input", err.Error())
+ assert.Error(t, err)
+ assert.Contains(t, err.Error(), "Unable to parse JSON")
logger.Close()
}
package log
import (
- "encoding/json"
+ "fmt"
"io"
"os"
+
+ jsoniter "github.com/json-iterator/go"
)
// CanColorStdout reports if we can color the Stdout
// Init inits connection writer with json config.
// json config only need key "level".
func (log *ConsoleLogger) Init(config string) error {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
err := json.Unmarshal([]byte(config), log)
if err != nil {
- return err
+ return fmt.Errorf("Unable to parse JSON: %v", err)
}
if log.Stderr {
log.NewWriterLogger(&nopWriteCloser{
logger := NewConsoleLogger()
err := logger.Init("{")
- assert.Equal(t, "unexpected end of JSON input", err.Error())
+ assert.Error(t, err)
+ assert.Contains(t, err.Error(), "Unable to parse JSON")
logger.Close()
}
import (
"bufio"
"compress/gzip"
- "encoding/json"
"errors"
"fmt"
"os"
"time"
"code.gitea.io/gitea/modules/util"
+ jsoniter "github.com/json-iterator/go"
)
// FileLogger implements LoggerProvider.
// "rotate":true
// }
func (log *FileLogger) Init(config string) error {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
if err := json.Unmarshal([]byte(config), log); err != nil {
- return err
+ return fmt.Errorf("Unable to parse JSON: %v", err)
}
if len(log.Filename) == 0 {
return errors.New("config must have filename")
import (
"bytes"
- "encoding/json"
"fmt"
"os"
"strings"
+
+ jsoniter "github.com/json-iterator/go"
)
// Level is the level of the logger
// UnmarshalJSON takes text and turns it into a Level
func (l *Level) UnmarshalJSON(b []byte) error {
var tmp interface{}
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
err := json.Unmarshal(b, &tmp)
if err != nil {
fmt.Fprintf(os.Stderr, "Err: %v", err)
package log
import (
- "encoding/json"
"fmt"
"testing"
+ jsoniter "github.com/json-iterator/go"
"github.com/stretchr/testify/assert"
)
}
func TestLevelMarshalUnmarshalJSON(t *testing.T) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
levelBytes, err := json.Marshal(testLevel{
Level: INFO,
})
package log
import (
- "encoding/json"
+ "fmt"
"net/smtp"
"strings"
+
+ jsoniter "github.com/json-iterator/go"
)
type smtpWriter struct {
// "level":LevelError
// }
func (log *SMTPLogger) Init(jsonconfig string) error {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
err := json.Unmarshal([]byte(jsonconfig), log)
if err != nil {
- return err
+ return fmt.Errorf("Unable to parse JSON: %v", err)
}
log.NewWriterLogger(&smtpWriter{
owner: log,
package action
import (
- "encoding/json"
"fmt"
"path"
"strings"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification/base"
"code.gitea.io/gitea/modules/repository"
+ jsoniter "github.com/json-iterator/go"
)
type actionNotifier struct {
}
func (a *actionNotifier) NotifyPushCommits(pusher *models.User, repo *models.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
data, err := json.Marshal(commits)
if err != nil {
log.Error("Marshal: %v", err)
}
func (a *actionNotifier) NotifySyncPushCommits(pusher *models.User, repo *models.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
data, err := json.Marshal(commits)
if err != nil {
log.Error("json.Marshal: %v", err)
package private
import (
- "encoding/json"
"fmt"
"net/http"
"net/url"
"time"
"code.gitea.io/gitea/modules/setting"
+ jsoniter "github.com/json-iterator/go"
)
// Git environment variables
)
req := newInternalRequest(reqURL, "POST")
req = req.Header("Content-Type", "application/json")
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
jsonBytes, _ := json.Marshal(opts)
req.Body(jsonBytes)
req.SetTimeout(60*time.Second, time.Duration(60+len(opts.OldCommitIDs))*time.Second)
req := newInternalRequest(reqURL, "POST")
req = req.Header("Content-Type", "application/json")
req.SetTimeout(60*time.Second, time.Duration(60+len(opts.OldCommitIDs))*time.Second)
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
jsonBytes, _ := json.Marshal(opts)
req.Body(jsonBytes)
resp, err := req.Response()
import (
"crypto/tls"
- "encoding/json"
"fmt"
"net"
"net/http"
"code.gitea.io/gitea/modules/httplib"
"code.gitea.io/gitea/modules/setting"
+ jsoniter "github.com/json-iterator/go"
)
func newRequest(url, method string) *httplib.Request {
func decodeJSONError(resp *http.Response) *Response {
var res Response
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
err := json.NewDecoder(resp.Body).Decode(&res)
if err != nil {
res.Err = err.Error()
package private
import (
- "encoding/json"
"fmt"
"io/ioutil"
"net/http"
"code.gitea.io/gitea/modules/setting"
+ jsoniter "github.com/json-iterator/go"
)
// Email structure holds a data for sending general emails
req := newInternalRequest(reqURL, "POST")
req = req.Header("Content-Type", "application/json")
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
jsonBytes, _ := json.Marshal(Email{
Subject: subject,
Message: message,
package private
import (
- "encoding/json"
"fmt"
"net/http"
"net/url"
"time"
"code.gitea.io/gitea/modules/setting"
+ jsoniter "github.com/json-iterator/go"
)
// Shutdown calls the internal shutdown function
req.SetTimeout(timeout+10*time.Second, timeout+10*time.Second)
}
req = req.Header("Content-Type", "application/json")
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
jsonBytes, _ := json.Marshal(FlushOptions{
Timeout: timeout,
NonBlocking: nonBlocking,
req := newInternalRequest(reqURL, "POST")
req = req.Header("Content-Type", "application/json")
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
jsonBytes, _ := json.Marshal(LoggerOptions{
Group: group,
Name: name,
package private
import (
- "encoding/json"
"fmt"
"net/http"
"net/url"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/setting"
+ jsoniter "github.com/json-iterator/go"
)
// KeyAndOwner is the response from ServNoCommand
}
var keyAndOwner KeyAndOwner
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
if err := json.NewDecoder(resp.Body).Decode(&keyAndOwner); err != nil {
return nil, nil, err
}
return nil, err
}
defer resp.Body.Close()
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
if resp.StatusCode != http.StatusOK {
var errServCommand ErrServCommand
if err := json.NewDecoder(resp.Body).Decode(&errServCommand); err != nil {
package queue
import (
- "encoding/json"
"reflect"
+
+ jsoniter "github.com/json-iterator/go"
)
// Mappable represents an interface that can MapTo another interface
// It will tolerate the cfg being passed as a []byte or string of a json representation of the
// exemplar or the correct type of the exemplar itself
func toConfig(exemplar, cfg interface{}) (interface{}, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
// First of all check if we've got the same type as the exemplar - if so it's all fine.
if reflect.TypeOf(cfg).AssignableTo(reflect.TypeOf(exemplar)) {
// unmarshalAs will attempt to unmarshal provided bytes as the provided exemplar
func unmarshalAs(bs []byte, exemplar interface{}) (data Data, err error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
if exemplar != nil {
t := reflect.TypeOf(exemplar)
n := reflect.New(t)
import (
"context"
- "encoding/json"
"fmt"
"reflect"
"sort"
"time"
"code.gitea.io/gitea/modules/log"
+ jsoniter "github.com/json-iterator/go"
)
var manager *Manager
configuration,
exemplar interface{}) int64 {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
cfg, _ := json.Marshal(configuration)
mq := &ManagedQueue{
Type: t,
import (
"context"
- "encoding/json"
"fmt"
"sync"
"time"
"code.gitea.io/gitea/modules/log"
+ jsoniter "github.com/json-iterator/go"
)
// ByteFIFOQueueConfiguration is the configuration for a ByteFIFOQueue
if !assignableTo(data, q.exemplar) {
return fmt.Errorf("Unable to assign data: %v to same type as exemplar: %v in %s", data, q.exemplar, q.name)
}
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
bs, err := json.Marshal(data)
if err != nil {
return err
if !assignableTo(data, q.exemplar) {
return false, fmt.Errorf("Unable to assign data: %v to same type as exemplar: %v in %s", data, q.exemplar, q.name)
}
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
bs, err := json.Marshal(data)
if err != nil {
return false, err
package queue
import (
- "encoding/json"
"testing"
+ jsoniter "github.com/json-iterator/go"
"github.com/stretchr/testify/assert"
)
assert.NotEqual(t, cfg2, exemplar)
assert.Equal(t, &cfg, &cfg2)
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
cfgString, err := json.Marshal(cfg)
assert.NoError(t, err)
package queue
import (
- "encoding/json"
"fmt"
"strings"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
+ jsoniter "github.com/json-iterator/go"
)
func validType(t string) (Type, error) {
func getQueueSettings(name string) (setting.QueueSettings, []byte) {
q := setting.GetQueueSettings(name)
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
cfg, err := json.Marshal(q)
if err != nil {
log.Error("Unable to marshall generic options: %v Error: %v", q, err)
import (
"context"
- "encoding/json"
"fmt"
"io/ioutil"
"net/http"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
+ jsoniter "github.com/json-iterator/go"
)
// Response is the structure of JSON returned from API
return false, fmt.Errorf("Failed to read CAPTCHA response: %s", err)
}
var jsonResponse Response
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
err = json.Unmarshal(body, &jsonResponse)
if err != nil {
return false, fmt.Errorf("Failed to parse CAPTCHA response: %s", err)
package session
import (
- "encoding/json"
"fmt"
"sync"
memcache "gitea.com/go-chi/session/memcache"
mysql "gitea.com/go-chi/session/mysql"
postgres "gitea.com/go-chi/session/postgres"
+ jsoniter "github.com/json-iterator/go"
)
// VirtualSessionProvider represents a shadowed session provider implementation.
// Init initializes the cookie session provider with given root path.
func (o *VirtualSessionProvider) Init(gclifetime int64, config string) error {
var opts session.Options
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
if err := json.Unmarshal([]byte(config), &opts); err != nil {
return err
}
package setting
import (
- "encoding/json"
"fmt"
golog "log"
"os"
"sync"
"code.gitea.io/gitea/modules/log"
+ jsoniter "github.com/json-iterator/go"
ini "gopkg.in/ini.v1"
)
logConfig["colorize"] = sec.Key("COLORIZE").MustBool(false)
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
byteConfig, err := json.Marshal(logConfig)
if err != nil {
log.Error("Failed to marshal log configuration: %v %v", logConfig, err)
package setting
import (
- "encoding/json"
"path"
"path/filepath"
"strings"
"code.gitea.io/gitea/modules/log"
+ jsoniter "github.com/json-iterator/go"
)
var (
SessionConfig.Maxlifetime = sec.Key("SESSION_LIFE_TIME").MustInt64(86400)
SessionConfig.Domain = sec.Key("DOMAIN").String()
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
shadowConfig, err := json.Marshal(SessionConfig)
if err != nil {
log.Fatal("Can't shadow session config: %v", err)
import (
"encoding/base64"
- "encoding/json"
"fmt"
"io"
"io/ioutil"
"code.gitea.io/gitea/modules/user"
"code.gitea.io/gitea/modules/util"
+ jsoniter "github.com/json-iterator/go"
shellquote "github.com/kballard/go-shellquote"
"github.com/unknwon/com"
gossh "golang.org/x/crypto/ssh"
Icons []manifestIcon `json:"icons"`
}
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
bytes, err := json.Marshal(&manifestJSON{
Name: appName,
ShortName: appName,
package setting
import (
- "encoding/json"
"testing"
+ jsoniter "github.com/json-iterator/go"
"github.com/stretchr/testify/assert"
)
func TestMakeManifestData(t *testing.T) {
jsonBytes := MakeManifestData(`Example App '\"`, "https://example.com", "https://example.com/foo/bar")
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
assert.True(t, json.Valid(jsonBytes))
}
package storage
import (
- "encoding/json"
"reflect"
+
+ jsoniter "github.com/json-iterator/go"
)
// Mappable represents an interface that can MapTo another interface
// It will tolerate the cfg being passed as a []byte or string of a json representation of the
// exemplar or the correct type of the exemplar itself
func toConfig(exemplar, cfg interface{}) (interface{}, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
// First of all check if we've got the same type as the exemplar - if so it's all fine.
if reflect.TypeOf(cfg).AssignableTo(reflect.TypeOf(exemplar)) {
package structs
import (
- "encoding/json"
"errors"
"strings"
"time"
+
+ jsoniter "github.com/json-iterator/go"
)
var (
// JSONPayload return payload information
func (p *CreatePayload) JSONPayload() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.MarshalIndent(p, "", " ")
}
// ParseCreateHook parses create event hook content.
func ParseCreateHook(raw []byte) (*CreatePayload, error) {
hook := new(CreatePayload)
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
if err := json.Unmarshal(raw, hook); err != nil {
return nil, err
}
// JSONPayload implements Payload
func (p *DeletePayload) JSONPayload() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.MarshalIndent(p, "", " ")
}
// JSONPayload implements Payload
func (p *ForkPayload) JSONPayload() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.MarshalIndent(p, "", " ")
}
// JSONPayload implements Payload
func (p *IssueCommentPayload) JSONPayload() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.MarshalIndent(p, "", " ")
}
// JSONPayload implements Payload
func (p *ReleasePayload) JSONPayload() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.MarshalIndent(p, "", " ")
}
// JSONPayload FIXME
func (p *PushPayload) JSONPayload() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.MarshalIndent(p, "", " ")
}
// ParsePushHook parses push event hook content.
func ParsePushHook(raw []byte) (*PushPayload, error) {
hook := new(PushPayload)
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
if err := json.Unmarshal(raw, hook); err != nil {
return nil, err
}
// JSONPayload encodes the IssuePayload to JSON, with an indentation of two spaces.
func (p *IssuePayload) JSONPayload() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.MarshalIndent(p, "", " ")
}
// JSONPayload FIXME
func (p *PullRequestPayload) JSONPayload() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.MarshalIndent(p, "", " ")
}
// JSONPayload JSON representation of the payload
func (p *RepositoryPayload) JSONPayload() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.MarshalIndent(p, "", " ")
}
package structs
import (
- "encoding/json"
"time"
+
+ jsoniter "github.com/json-iterator/go"
)
// User represents a user
func (u User) MarshalJSON() ([]byte, error) {
// Re-declaring User to avoid recursion
type shadow User
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
return json.Marshal(struct {
shadow
CompatUserName string `json:"username"`
package task
import (
- "encoding/json"
"fmt"
"code.gitea.io/gitea/models"
repo_module "code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/timeutil"
+ jsoniter "github.com/json-iterator/go"
)
// taskQueue is a global queue of tasks
// CreateMigrateTask creates a migrate task
func CreateMigrateTask(doer, u *models.User, opts base.MigrateOptions) (*models.Task, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
bs, err := json.Marshal(&opts)
if err != nil {
return nil, err
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
// 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())
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 ""
}
// 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)
}
package admin
import (
- "encoding/json"
"fmt"
"net/url"
"os"
"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"
)
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)
}
package utils
import (
- "encoding/json"
"fmt"
"net/http"
"strings"
"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
return nil, false
}
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
meta, err := json.Marshal(&webhook.SlackMeta{
Channel: strings.TrimSpace(channel),
Username: form.Config["username"],
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"],
package events
import (
- "encoding/json"
"net/http"
"time"
"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
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)
package private
import (
- "encoding/json"
"fmt"
"net/http"
"strconv"
"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
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{}{
package private
import (
- "encoding/json"
"fmt"
"net/http"
"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
}
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)
package repo
import (
- "encoding/json"
"fmt"
"io/ioutil"
"path"
"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 (
if err == nil {
def, err := ec.GetDefinitionForFilename(treePath)
if err == nil {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
jsonStr, _ := json.Marshal(def)
return string(jsonStr)
}
package repo
import (
- "encoding/json"
"errors"
"fmt"
"path"
"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 (
return
}
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
meta, err := json.Marshal(&webhook.DiscordMeta{
Username: form.Username,
IconURL: form.IconURL,
return
}
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
meta, err := json.Marshal(&webhook.TelegramMeta{
BotToken: form.BotToken,
ChatID: form.ChatID,
return
}
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
meta, err := json.Marshal(&webhook.MatrixMeta{
HomeserverURL: form.HomeserverURL,
Room: form.RoomID,
return
}
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
meta, err := json.Marshal(&webhook.SlackMeta{
Channel: strings.TrimSpace(form.Channel),
Username: form.Username,
return
}
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
meta, err := json.Marshal(&webhook.SlackMeta{
Channel: strings.TrimSpace(form.Channel),
Username: form.Username,
return
}
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
meta, err := json.Marshal(&webhook.DiscordMeta{
Username: form.Username,
IconURL: form.IconURL,
ctx.HTML(200, orCtx.NewTemplate)
return
}
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
meta, err := json.Marshal(&webhook.TelegramMeta{
BotToken: form.BotToken,
ChatID: form.ChatID,
ctx.HTML(200, orCtx.NewTemplate)
return
}
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
meta, err := json.Marshal(&webhook.MatrixMeta{
HomeserverURL: form.HomeserverURL,
Room: form.RoomID,
import (
"bytes"
- "encoding/json"
"fmt"
"regexp"
"sort"
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"
}
// Convert []int64 to string
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
reposParam, _ := json.Marshal(repoIDs)
ctx.Data["ReposParam"] = string(reposParam)
package gitdiff
import (
- "encoding/json"
"fmt"
"html/template"
"strconv"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/highlight"
"code.gitea.io/gitea/modules/setting"
+ jsoniter "github.com/json-iterator/go"
dmp "github.com/sergi/go-diff/diffmatchpatch"
"github.com/stretchr/testify/assert"
"gopkg.in/ini.v1"
t.Errorf("ParsePatch(%q) error = %v, wantErr %v", testcase.name, err, testcase.wantErr)
return
}
- gotMarshaled, _ := json.MarshalIndent(got, " ", " ")
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
+ gotMarshaled, _ := json.MarshalIndent(got, "", " ")
if got.NumFiles != 1 {
t.Errorf("ParsePath(%q) did not receive 1 file:\n%s", testcase.name, string(gotMarshaled))
return
"bufio"
"bytes"
"context"
- "encoding/json"
"errors"
"fmt"
"strings"
"code.gitea.io/gitea/modules/notification"
"code.gitea.io/gitea/modules/setting"
issue_service "code.gitea.io/gitea/services/issue"
+ jsoniter "github.com/json-iterator/go"
)
// NewPullRequest creates new pull request with labels for repository.
data.CommitIDs = append(data.CommitIDs, e.Value.(*git.Commit).ID.String())
}
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
dataJSON, err := json.Marshal(data)
if err != nil {
return err
package webhook
import (
- "encoding/json"
"fmt"
"strings"
"code.gitea.io/gitea/modules/git"
api "code.gitea.io/gitea/modules/structs"
+ jsoniter "github.com/json-iterator/go"
dingtalk "github.com/lunny/dingtalk_webhook"
)
// JSONPayload Marshals the DingtalkPayload to json
func (d *DingtalkPayload) JSONPayload() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
data, err := json.MarshalIndent(d, "", " ")
if err != nil {
return []byte{}, err
package webhook
import (
- "encoding/json"
"errors"
"fmt"
"strconv"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
+ jsoniter "github.com/json-iterator/go"
)
type (
// GetDiscordHook returns discord metadata
func GetDiscordHook(w *models.Webhook) *DiscordMeta {
s := &DiscordMeta{}
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
if err := json.Unmarshal([]byte(w.Meta), s); err != nil {
log.Error("webhook.GetDiscordHook(%d): %v", w.ID, err)
}
// JSONPayload Marshals the DiscordPayload to json
func (d *DiscordPayload) JSONPayload() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
data, err := json.MarshalIndent(d, "", " ")
if err != nil {
return []byte{}, err
s := new(DiscordPayload)
discord := &DiscordMeta{}
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
if err := json.Unmarshal([]byte(meta), &discord); err != nil {
return s, errors.New("GetDiscordPayload meta json:" + err.Error())
}
package webhook
import (
- "encoding/json"
"fmt"
"strings"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/git"
api "code.gitea.io/gitea/modules/structs"
+ jsoniter "github.com/json-iterator/go"
)
type (
// JSONPayload Marshals the FeishuPayload to json
func (f *FeishuPayload) JSONPayload() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
data, err := json.MarshalIndent(f, "", " ")
if err != nil {
return []byte{}, err
import (
"crypto/sha1"
- "encoding/json"
"errors"
"fmt"
"html"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
+ jsoniter "github.com/json-iterator/go"
)
const matrixPayloadSizeLimit = 1024 * 64
// GetMatrixHook returns Matrix metadata
func GetMatrixHook(w *models.Webhook) *MatrixMeta {
s := &MatrixMeta{}
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
if err := json.Unmarshal([]byte(w.Meta), s); err != nil {
log.Error("webhook.GetMatrixHook(%d): %v", w.ID, err)
}
// JSONPayload Marshals the MatrixPayloadUnsafe to json
func (m *MatrixPayloadUnsafe) JSONPayload() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
data, err := json.MarshalIndent(m, "", " ")
if err != nil {
return []byte{}, err
s := new(MatrixPayloadUnsafe)
matrix := &MatrixMeta{}
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
if err := json.Unmarshal([]byte(meta), &matrix); err != nil {
return s, errors.New("GetMatrixPayload meta json:" + err.Error())
}
// The access_token is removed from t.PayloadContent
func getMatrixHookRequest(t *models.HookTask) (*http.Request, error) {
payloadunsafe := MatrixPayloadUnsafe{}
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
if err := json.Unmarshal([]byte(t.PayloadContent), &payloadunsafe); err != nil {
log.Error("Matrix Hook delivery failed: %v", err)
return nil, err
package webhook
import (
- "encoding/json"
"fmt"
"strings"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/git"
api "code.gitea.io/gitea/modules/structs"
+ jsoniter "github.com/json-iterator/go"
)
type (
// JSONPayload Marshals the MSTeamsPayload to json
func (m *MSTeamsPayload) JSONPayload() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
data, err := json.MarshalIndent(m, "", " ")
if err != nil {
return []byte{}, err
package webhook
import (
- "encoding/json"
"errors"
"fmt"
"strings"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
+ jsoniter "github.com/json-iterator/go"
)
// SlackMeta contains the slack metadata
// GetSlackHook returns slack metadata
func GetSlackHook(w *models.Webhook) *SlackMeta {
s := &SlackMeta{}
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
if err := json.Unmarshal([]byte(w.Meta), s); err != nil {
log.Error("webhook.GetSlackHook(%d): %v", w.ID, err)
}
// JSONPayload Marshals the SlackPayload to json
func (s *SlackPayload) JSONPayload() ([]byte, error) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
data, err := json.MarshalIndent(s, "", " ")
if err != nil {
return []byte{}, err
s := new(SlackPayload)
slack := &SlackMeta{}
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
if err := json.Unmarshal([]byte(meta), &slack); err != nil {
return s, errors.New("GetSlackPayload meta json:" + err.Error())
}
package webhook
import (
- "encoding/json"
"fmt"
"strings"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/markup"
api "code.gitea.io/gitea/modules/structs"
+ jsoniter "github.com/json-iterator/go"
)
type (
// GetTelegramHook returns telegram metadata
func GetTelegramHook(w *models.Webhook) *TelegramMeta {
s := &TelegramMeta{}
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
if err := json.Unmarshal([]byte(w.Meta), s); err != nil {
log.Error("webhook.GetTelegramHook(%d): %v", w.ID, err)
}
t.ParseMode = "HTML"
t.DisableWebPreview = true
t.Message = markup.Sanitize(t.Message)
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
data, err := json.MarshalIndent(t, "", " ")
if err != nil {
return []byte{}, err
package binding
import (
- "encoding/json"
"fmt"
"io"
"mime/multipart"
"strings"
"unicode/utf8"
+ jsoniter "github.com/json-iterator/go"
"github.com/unknwon/com"
)
} else {
rw.WriteHeader(STATUS_UNPROCESSABLE_ENTITY)
}
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
errOutput, _ := json.Marshal(errs)
rw.Write(errOutput)
return
if req.Body != nil {
defer req.Body.Close()
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
err := json.NewDecoder(req.Body).Decode(jsonStruct)
if err != nil && err != io.EOF {
errors.Add([]string{}, ERR_DESERIALIZATION, err.Error())
require (
github.com/go-chi/chi v1.5.1
+ github.com/json-iterator/go v1.1.10
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337
github.com/unknwon/com v0.0.0-20190804042917-757f69c95f3e
)
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-chi/chi v1.5.1 h1:kfTK3Cxd/dkMu/rKs5ZceWYp+t5CtiE7vmaTv3LjC6w=
github.com/go-chi/chi v1.5.1/go.mod h1:REp24E+25iKvxgeTfHmdUoL5x15kBiDBlnIl5bCwe2k=
+github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e h1:JKmoR8x90Iww1ks85zJ1lfDGgIiMDuIptTOhJq+zKyg=
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
+github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68=
+github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
+github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
+github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg=
+github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304 h1:Jpy1PXuP99tXNrhbq2BaPz9B+jNAvH1JPQQpG/9GCXY=
github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s=
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337 h1:WN9BUFbdyOsSH/XohnWpXOlq9NBD5sGAB2FciQMUEe8=
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
+github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/unknwon/com v0.0.0-20190804042917-757f69c95f3e h1:GSGeB9EAKY2spCABz6xOX5DbxZEXolK+nBSvmsQwRjM=
github.com/unknwon/com v0.0.0-20190804042917-757f69c95f3e/go.mod h1:tOOxU81rwgoCLoOVVPHb6T/wt8HZygqH5id+GNnlCXM=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
# code.gitea.io/sdk/gitea v0.13.2
## explicit
code.gitea.io/sdk/gitea
-# gitea.com/go-chi/binding v0.0.0-20210113025129-03f1d313373c
+# gitea.com/go-chi/binding v0.0.0-20210301195521-1fe1c9a555e7
## explicit
gitea.com/go-chi/binding
# gitea.com/go-chi/cache v0.0.0-20210110083709-82c4c9ce2d5e
# github.com/josharian/intern v1.0.0
github.com/josharian/intern
# github.com/json-iterator/go v1.1.10
+## explicit
github.com/json-iterator/go
# github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
## explicit