mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-21 12:44:49 -05:00
Add an abstract json layout to make it's easier to change json library (#16528)
* Add an abstract json layout to make it's easier to change json library * Fix import * Fix import sequence * Fix blank lines * Fix blank lines
This commit is contained in:
parent
e0f9635c06
commit
9f31f3aa8a
93 changed files with 272 additions and 264 deletions
|
@ -20,7 +20,7 @@ import (
|
|||
"strings"
|
||||
"unicode/utf8"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -51,7 +51,6 @@ func (e Emoji) MarshalJSON() ([]byte, error) {
|
|||
x.UnicodeVersion = ""
|
||||
x.Description = ""
|
||||
x.SkinTones = false
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
return json.Marshal(x)
|
||||
}
|
||||
|
||||
|
@ -103,7 +102,6 @@ func generate() ([]byte, error) {
|
|||
|
||||
// unmarshal
|
||||
var data Gemoji
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
err = json.Unmarshal(body, &data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -15,13 +15,13 @@ import (
|
|||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/storage"
|
||||
"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"
|
||||
)
|
||||
|
@ -306,7 +306,6 @@ func runDump(ctx *cli.Context) error {
|
|||
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
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import (
|
|||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/pprof"
|
||||
"code.gitea.io/gitea/modules/private"
|
||||
|
@ -24,7 +25,6 @@ import (
|
|||
"code.gitea.io/gitea/services/lfs"
|
||||
|
||||
"github.com/golang-jwt/jwt"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/kballard/go-shellquote"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
@ -265,7 +265,6 @@ func runServ(c *cli.Context) error {
|
|||
}
|
||||
tokenAuthentication.Header["Authorization"] = fmt.Sprintf("Bearer %s", tokenString)
|
||||
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
enc := json.NewEncoder(os.Stdout)
|
||||
err = enc.Encode(tokenAuthentication)
|
||||
if err != nil {
|
||||
|
|
|
@ -10,9 +10,9 @@ import (
|
|||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
@ -190,7 +190,6 @@ func TestAPIEditUser(t *testing.T) {
|
|||
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))
|
||||
|
||||
|
|
|
@ -14,11 +14,11 @@ import (
|
|||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/queue"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/services/forms"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
@ -231,7 +231,6 @@ func doAPICreatePullRequest(ctx APITestContext, owner, repo, baseBranch, headBra
|
|||
}
|
||||
resp := ctx.Session.MakeRequest(t, req, expected)
|
||||
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
decoder := json.NewDecoder(resp.Body)
|
||||
pr := api.PullRequest{}
|
||||
err := decoder.Decode(&pr)
|
||||
|
@ -251,7 +250,6 @@ func doAPIGetPullRequest(ctx APITestContext, owner, repo string, index int64) fu
|
|||
}
|
||||
resp := ctx.Session.MakeRequest(t, req, expected)
|
||||
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
decoder := json.NewDecoder(resp.Body)
|
||||
pr := api.PullRequest{}
|
||||
err := decoder.Decode(&pr)
|
||||
|
|
|
@ -10,8 +10,9 @@ import (
|
|||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
@ -189,7 +190,6 @@ func TestAPIPullReview(t *testing.T) {
|
|||
})
|
||||
resp = session.MakeRequest(t, req, http.StatusUnprocessableEntity)
|
||||
errMap := make(map[string]interface{})
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
json.Unmarshal(resp.Body.Bytes(), &errMap)
|
||||
assert.EqualValues(t, "review event COMMENT requires a body or a comment", errMap["message"].(string))
|
||||
|
||||
|
|
|
@ -13,10 +13,10 @@ import (
|
|||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/lfs"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
@ -86,7 +86,6 @@ func TestAPILFSBatch(t *testing.T) {
|
|||
decodeResponse := func(t *testing.T, b *bytes.Buffer) *lfs.BatchResponse {
|
||||
var br lfs.BatchResponse
|
||||
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
assert.NoError(t, json.Unmarshal(b.Bytes(), &br))
|
||||
return &br
|
||||
}
|
||||
|
|
|
@ -12,12 +12,12 @@ import (
|
|||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
"code.gitea.io/gitea/routers"
|
||||
|
||||
"gitea.com/go-chi/session"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
@ -63,7 +63,6 @@ func TestSessionFileCreation(t *testing.T) {
|
|||
|
||||
var config session.Options
|
||||
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
err := json.Unmarshal([]byte(oldSessionConfig), &config)
|
||||
assert.NoError(t, err)
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ import (
|
|||
"code.gitea.io/gitea/modules/base"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/graceful"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/queue"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
|
@ -37,7 +38,6 @@ import (
|
|||
"code.gitea.io/gitea/routers"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
@ -416,7 +416,6 @@ func NewRequestWithValues(t testing.TB, method, urlStr string, values map[string
|
|||
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))
|
||||
|
@ -508,7 +507,6 @@ func logUnexpectedResponse(t testing.TB, recorder *httptest.ResponseRecorder) {
|
|||
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))
|
||||
}
|
||||
|
|
|
@ -14,11 +14,11 @@ import (
|
|||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/lfs"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/routers/web"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
gzipp "github.com/klauspost/compress/gzip"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
@ -206,7 +206,7 @@ func TestGetLFSRange(t *testing.T) {
|
|||
assert.Equal(t, tt.out, resp.Body.String())
|
||||
} else {
|
||||
var er lfs.ErrorResponse
|
||||
err := jsoniter.Unmarshal(resp.Body.Bytes(), &er)
|
||||
err := json.Unmarshal(resp.Body.Bytes(), &er)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, tt.out, er.Message)
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ import (
|
|||
"io/ioutil"
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
@ -71,7 +71,6 @@ func TestAccessTokenExchange(t *testing.T) {
|
|||
}
|
||||
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)
|
||||
|
@ -96,7 +95,6 @@ func TestAccessTokenExchangeWithoutPKCE(t *testing.T) {
|
|||
}
|
||||
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)
|
||||
|
@ -186,7 +184,6 @@ func TestAccessTokenExchangeWithBasicAuth(t *testing.T) {
|
|||
}
|
||||
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)
|
||||
|
@ -230,7 +227,6 @@ func TestRefreshTokenInvalidation(t *testing.T) {
|
|||
}
|
||||
parsed := new(response)
|
||||
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
assert.NoError(t, json.Unmarshal(resp.Body.Bytes(), parsed))
|
||||
|
||||
// test without invalidation
|
||||
|
|
|
@ -10,10 +10,10 @@ import (
|
|||
"path"
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
@ -86,7 +86,6 @@ func doTestRepoCommitWithStatus(t *testing.T, state string, classes ...string) {
|
|||
}
|
||||
|
||||
func testRepoCommitsWithStatus(t *testing.T, resp, respOne *httptest.ResponseRecorder, state string) {
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
var statuses []*api.CommitStatus
|
||||
assert.NoError(t, json.Unmarshal(resp.Body.Bytes(), &statuses))
|
||||
var status api.CombinedStatus
|
||||
|
|
|
@ -14,9 +14,9 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/queue"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -158,7 +158,6 @@ func NewTestLogger() log.LoggerProvider {
|
|||
// 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
|
||||
|
|
|
@ -7,7 +7,7 @@ package models
|
|||
import (
|
||||
"encoding/binary"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
)
|
||||
|
||||
func keysInt64(m map[int64]struct{}) []int64 {
|
||||
|
@ -37,7 +37,6 @@ func valuesUser(m map[int64]*User) []*User {
|
|||
// JSONUnmarshalHandleDoubleEncode - due to a bug in xorm (see https://gitea.com/xorm/xorm/pulls/1957) - it's
|
||||
// possible that a Blob may be double encoded or gain an unwanted prefix of 0xff 0xfe.
|
||||
func JSONUnmarshalHandleDoubleEncode(bs []byte, v interface{}) error {
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
err := json.Unmarshal(bs, v)
|
||||
if err != nil {
|
||||
ok := true
|
||||
|
|
|
@ -15,13 +15,13 @@ import (
|
|||
"unicode/utf8"
|
||||
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/markup"
|
||||
"code.gitea.io/gitea/modules/markup/markdown"
|
||||
"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"
|
||||
|
@ -654,7 +654,6 @@ func (c *Comment) LoadPushCommits() (err error) {
|
|||
|
||||
var data PushActionContent
|
||||
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
err = json.Unmarshal([]byte(c.Content), &data)
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -1249,7 +1248,6 @@ func CreatePushPullComment(pusher *User, pr *PullRequest, oldCommitID, newCommit
|
|||
|
||||
ops.Issue = pr.Issue
|
||||
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
dataJSON, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -14,9 +14,9 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/queue"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -158,7 +158,6 @@ func NewTestLogger() log.LoggerProvider {
|
|||
// 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
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
package migrations
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
@ -70,7 +70,6 @@ func expandWebhooks(x *xorm.Engine) error {
|
|||
|
||||
for _, res := range results {
|
||||
var events HookEvent
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
if err = json.Unmarshal([]byte(res.Events), &events); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
package migrations
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"xorm.io/builder"
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
@ -105,7 +105,6 @@ func removeCredentials(payload string) (string, error) {
|
|||
}
|
||||
|
||||
var opts MigrateOptions
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
err := json.Unmarshal([]byte(payload), &opts)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
|
|
@ -8,13 +8,13 @@ import (
|
|||
"encoding/binary"
|
||||
"fmt"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
func unwrapLDAPSourceCfg(x *xorm.Engine) error {
|
||||
jsonUnmarshalHandleDoubleEncode := func(bs []byte, v interface{}) error {
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
err := json.Unmarshal(bs, v)
|
||||
if err != nil {
|
||||
ok := true
|
||||
|
@ -84,7 +84,7 @@ func unwrapLDAPSourceCfg(x *xorm.Engine) error {
|
|||
return fmt.Errorf("failed to unmarshal %s: %w", string(source.Cfg), err)
|
||||
}
|
||||
if wrapped.Source != nil && len(wrapped.Source) > 0 {
|
||||
bs, err := jsoniter.Marshal(wrapped.Source)
|
||||
bs, err := json.Marshal(wrapped.Source)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -7,7 +7,8 @@ package migrations
|
|||
import (
|
||||
"testing"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
@ -65,12 +66,12 @@ func Test_unwrapLDAPSourceCfg(t *testing.T) {
|
|||
converted := map[string]interface{}{}
|
||||
expected := map[string]interface{}{}
|
||||
|
||||
if err := jsoniter.Unmarshal([]byte(source.Cfg), &converted); err != nil {
|
||||
if err := json.Unmarshal([]byte(source.Cfg), &converted); err != nil {
|
||||
assert.NoError(t, err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := jsoniter.Unmarshal([]byte(source.Expected), &expected); err != nil {
|
||||
if err := json.Unmarshal([]byte(source.Expected), &expected); err != nil {
|
||||
assert.NoError(t, err)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -7,9 +7,9 @@ package models
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"xorm.io/xorm"
|
||||
"xorm.io/xorm/convert"
|
||||
)
|
||||
|
@ -33,7 +33,6 @@ func (cfg *UnitConfig) FromDB(bs []byte) error {
|
|||
|
||||
// ToDB exports a UnitConfig to a serialized format.
|
||||
func (cfg *UnitConfig) ToDB() ([]byte, error) {
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
return json.Marshal(cfg)
|
||||
}
|
||||
|
||||
|
@ -49,7 +48,6 @@ func (cfg *ExternalWikiConfig) FromDB(bs []byte) error {
|
|||
|
||||
// ToDB exports a ExternalWikiConfig to a serialized format.
|
||||
func (cfg *ExternalWikiConfig) ToDB() ([]byte, error) {
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
return json.Marshal(cfg)
|
||||
}
|
||||
|
||||
|
@ -67,7 +65,6 @@ func (cfg *ExternalTrackerConfig) FromDB(bs []byte) error {
|
|||
|
||||
// ToDB exports a ExternalTrackerConfig to a serialized format.
|
||||
func (cfg *ExternalTrackerConfig) ToDB() ([]byte, error) {
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
return json.Marshal(cfg)
|
||||
}
|
||||
|
||||
|
@ -85,7 +82,6 @@ func (cfg *IssuesConfig) FromDB(bs []byte) error {
|
|||
|
||||
// ToDB exports a IssuesConfig to a serialized format.
|
||||
func (cfg *IssuesConfig) ToDB() ([]byte, error) {
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
return json.Marshal(cfg)
|
||||
}
|
||||
|
||||
|
@ -109,7 +105,6 @@ func (cfg *PullRequestsConfig) FromDB(bs []byte) error {
|
|||
|
||||
// ToDB exports a PullRequestsConfig to a serialized format.
|
||||
func (cfg *PullRequestsConfig) ToDB() ([]byte, error) {
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
return json.Marshal(cfg)
|
||||
}
|
||||
|
||||
|
|
|
@ -7,13 +7,13 @@ package models
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
migration "code.gitea.io/gitea/modules/migrations/base"
|
||||
"code.gitea.io/gitea/modules/secret"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
|
||||
"xorm.io/builder"
|
||||
)
|
||||
|
@ -114,7 +114,6 @@ func (task *Task) UpdateCols(cols ...string) error {
|
|||
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
|
||||
|
@ -190,7 +189,6 @@ func GetMigratingTaskByID(id, doerID int64) (*Task, *migration.MigrateOptions, e
|
|||
}
|
||||
|
||||
var opts migration.MigrateOptions
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
if err := json.Unmarshal([]byte(task.PayloadContent), &opts); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
@ -244,7 +242,6 @@ func FinishMigrateTask(task *Task) error {
|
|||
conf.AuthPasswordEncrypted = ""
|
||||
conf.AuthTokenEncrypted = ""
|
||||
conf.CloneAddrEncrypted = ""
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
confBytes, err := json.Marshal(conf)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -8,7 +8,8 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
@ -68,7 +69,6 @@ func TestGetUserHeatmapDataByUser(t *testing.T) {
|
|||
assert.Equal(t, tc.CountResult, contributions, 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))
|
||||
|
|
|
@ -11,13 +11,13 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"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
|
||||
|
@ -160,8 +160,6 @@ type Webhook struct {
|
|||
// 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)
|
||||
}
|
||||
|
@ -174,7 +172,6 @@ func (w *Webhook) History(page int) ([]*HookTask, error) {
|
|||
|
||||
// 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
|
||||
|
@ -687,7 +684,6 @@ func (t *HookTask) AfterLoad() {
|
|||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
@ -701,7 +697,6 @@ func (t *HookTask) AfterLoad() {
|
|||
}
|
||||
|
||||
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)
|
||||
|
|
|
@ -9,9 +9,9 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
@ -58,7 +58,6 @@ func TestWebhook_UpdateEvent(t *testing.T) {
|
|||
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)
|
||||
}
|
||||
|
|
4
modules/cache/cache_twoqueue.go
vendored
4
modules/cache/cache_twoqueue.go
vendored
|
@ -9,9 +9,10 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
|
||||
mc "gitea.com/go-chi/cache"
|
||||
lru "github.com/hashicorp/golang-lru"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
// TwoQueueCache represents a LRU 2Q cache adapter implementation
|
||||
|
@ -177,7 +178,6 @@ func (c *TwoQueueCache) StartAndGC(opts mc.Options) error {
|
|||
size, err = strconv.Atoi(opts.AdapterConfig)
|
||||
}
|
||||
if err != nil {
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
if !json.Valid([]byte(opts.AdapterConfig)) {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/base"
|
||||
mc "code.gitea.io/gitea/modules/cache"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/templates"
|
||||
|
@ -34,7 +35,6 @@ import (
|
|||
"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"
|
||||
|
@ -408,7 +408,6 @@ func (ctx *Context) Error(status int, contents ...string) {
|
|||
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)
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
)
|
||||
|
||||
func wrapNewlines(w io.Writer, prefix []byte, value []byte) (sum int64, err error) {
|
||||
|
@ -80,7 +80,6 @@ func (e *Event) WriteTo(w io.Writer) (int64, error) {
|
|||
data = []byte(v)
|
||||
default:
|
||||
var err error
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
data, err = json.Marshal(e.Data)
|
||||
if err != nil {
|
||||
return sum, err
|
||||
|
@ -91,7 +90,6 @@ func (e *Event) WriteTo(w io.Writer) (int64, error) {
|
|||
if err != nil {
|
||||
return sum, err
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
n, err = wrapNewlines(w, []byte("id: "), []byte(e.ID))
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
)
|
||||
|
||||
var defaultSetting = Settings{false, "GiteaServer", 60 * time.Second, 60 * time.Second, nil, nil, nil, false}
|
||||
|
@ -443,7 +443,6 @@ func (r *Request) ToJSON(v interface{}) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
err = json.Unmarshal(data, v)
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -18,13 +18,13 @@ import (
|
|||
"code.gitea.io/gitea/modules/analyze"
|
||||
"code.gitea.io/gitea/modules/charset"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
"code.gitea.io/gitea/modules/typesniffer"
|
||||
|
||||
"github.com/go-enry/go-enry/v2"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/olivere/elastic/v7"
|
||||
)
|
||||
|
||||
|
@ -321,7 +321,6 @@ func convertResult(searchResult *elastic.SearchResult, kw string, pageSize int)
|
|||
|
||||
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
|
||||
}
|
||||
|
|
142
modules/json/json.go
Normal file
142
modules/json/json.go
Normal file
|
@ -0,0 +1,142 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package json
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"io"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
// Encoder represents an encoder for json
|
||||
type Encoder interface {
|
||||
Encode(v interface{}) error
|
||||
}
|
||||
|
||||
// Decoder represents a decoder for json
|
||||
type Decoder interface {
|
||||
Decode(v interface{}) error
|
||||
}
|
||||
|
||||
// Interface represents an interface to handle json data
|
||||
type Interface interface {
|
||||
Marshal(v interface{}) ([]byte, error)
|
||||
Unmarshal(data []byte, v interface{}) error
|
||||
NewEncoder(writer io.Writer) Encoder
|
||||
NewDecoder(reader io.Reader) Decoder
|
||||
Indent(dst *bytes.Buffer, src []byte, prefix, indent string) error
|
||||
}
|
||||
|
||||
var (
|
||||
// DefaultJSONHandler default json handler
|
||||
DefaultJSONHandler Interface = JSONiter{jsoniter.ConfigCompatibleWithStandardLibrary}
|
||||
|
||||
_ Interface = StdJSON{}
|
||||
_ Interface = JSONiter{}
|
||||
)
|
||||
|
||||
// StdJSON implements Interface via encoding/json
|
||||
type StdJSON struct{}
|
||||
|
||||
// Marshal implements Interface
|
||||
func (StdJSON) Marshal(v interface{}) ([]byte, error) {
|
||||
return json.Marshal(v)
|
||||
}
|
||||
|
||||
// Unmarshal implements Interface
|
||||
func (StdJSON) Unmarshal(data []byte, v interface{}) error {
|
||||
return json.Unmarshal(data, v)
|
||||
}
|
||||
|
||||
// NewEncoder implements Interface
|
||||
func (StdJSON) NewEncoder(writer io.Writer) Encoder {
|
||||
return json.NewEncoder(writer)
|
||||
}
|
||||
|
||||
// NewDecoder implements Interface
|
||||
func (StdJSON) NewDecoder(reader io.Reader) Decoder {
|
||||
return json.NewDecoder(reader)
|
||||
}
|
||||
|
||||
// Indent implements Interface
|
||||
func (StdJSON) Indent(dst *bytes.Buffer, src []byte, prefix, indent string) error {
|
||||
return json.Indent(dst, src, prefix, indent)
|
||||
}
|
||||
|
||||
// JSONiter implements Interface via jsoniter
|
||||
type JSONiter struct {
|
||||
jsoniter.API
|
||||
}
|
||||
|
||||
// Marshal implements Interface
|
||||
func (j JSONiter) Marshal(v interface{}) ([]byte, error) {
|
||||
return j.API.Marshal(v)
|
||||
}
|
||||
|
||||
// Unmarshal implements Interface
|
||||
func (j JSONiter) Unmarshal(data []byte, v interface{}) error {
|
||||
return j.API.Unmarshal(data, v)
|
||||
}
|
||||
|
||||
// NewEncoder implements Interface
|
||||
func (j JSONiter) NewEncoder(writer io.Writer) Encoder {
|
||||
return j.API.NewEncoder(writer)
|
||||
}
|
||||
|
||||
// NewDecoder implements Interface
|
||||
func (j JSONiter) NewDecoder(reader io.Reader) Decoder {
|
||||
return j.API.NewDecoder(reader)
|
||||
}
|
||||
|
||||
// Indent implements Interface, since jsoniter don't support Indent, just use encoding/json's
|
||||
func (j JSONiter) Indent(dst *bytes.Buffer, src []byte, prefix, indent string) error {
|
||||
return json.Indent(dst, src, prefix, indent)
|
||||
}
|
||||
|
||||
// Marshal converts object as bytes
|
||||
func Marshal(v interface{}) ([]byte, error) {
|
||||
return DefaultJSONHandler.Marshal(v)
|
||||
}
|
||||
|
||||
// Unmarshal decodes object from bytes
|
||||
func Unmarshal(data []byte, v interface{}) error {
|
||||
return DefaultJSONHandler.Unmarshal(data, v)
|
||||
}
|
||||
|
||||
// NewEncoder creates an encoder to write objects to writer
|
||||
func NewEncoder(writer io.Writer) Encoder {
|
||||
return DefaultJSONHandler.NewEncoder(writer)
|
||||
}
|
||||
|
||||
// NewDecoder creates a decoder to read objects from reader
|
||||
func NewDecoder(reader io.Reader) Decoder {
|
||||
return DefaultJSONHandler.NewDecoder(reader)
|
||||
}
|
||||
|
||||
// Indent appends to dst an indented form of the JSON-encoded src.
|
||||
func Indent(dst *bytes.Buffer, src []byte, prefix, indent string) error {
|
||||
return DefaultJSONHandler.Indent(dst, src, prefix, indent)
|
||||
}
|
||||
|
||||
// MarshalIndent copied from encoding/json
|
||||
func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) {
|
||||
b, err := Marshal(v)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
err = Indent(&buf, b, prefix, indent)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
// Valid proxy to json.Valid
|
||||
func Valid(data []byte) bool {
|
||||
return json.Valid(data)
|
||||
}
|
|
@ -13,9 +13,8 @@ import (
|
|||
"net/url"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
const batchSize = 20
|
||||
|
@ -69,7 +68,7 @@ func (c *HTTPClient) batch(ctx context.Context, operation string, objects []Poin
|
|||
request := &BatchRequest{operation, c.transferNames(), nil, objects}
|
||||
|
||||
payload := new(bytes.Buffer)
|
||||
err := jsoniter.NewEncoder(payload).Encode(request)
|
||||
err := json.NewEncoder(payload).Encode(request)
|
||||
if err != nil {
|
||||
log.Error("Error encoding json: %v", err)
|
||||
return nil, err
|
||||
|
@ -102,7 +101,7 @@ func (c *HTTPClient) batch(ctx context.Context, operation string, objects []Poin
|
|||
}
|
||||
|
||||
var response BatchResponse
|
||||
err = jsoniter.NewDecoder(res.Body).Decode(&response)
|
||||
err = json.NewDecoder(res.Body).Decode(&response)
|
||||
if err != nil {
|
||||
log.Error("Error decoding json: %v", err)
|
||||
return nil, err
|
||||
|
|
|
@ -13,7 +13,8 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
@ -146,7 +147,7 @@ func lfsTestRoundtripHandler(req *http.Request) *http.Response {
|
|||
}
|
||||
|
||||
payload := new(bytes.Buffer)
|
||||
jsoniter.NewEncoder(payload).Encode(batchResponse)
|
||||
json.NewEncoder(payload).Encode(batchResponse)
|
||||
|
||||
return &http.Response{StatusCode: http.StatusOK, Body: ioutil.NopCloser(payload)}
|
||||
}
|
||||
|
@ -160,7 +161,7 @@ func TestHTTPClientDownload(t *testing.T) {
|
|||
assert.Equal(t, MediaType, req.Header.Get("Accept"))
|
||||
|
||||
var batchRequest BatchRequest
|
||||
err := jsoniter.NewDecoder(req.Body).Decode(&batchRequest)
|
||||
err := json.NewDecoder(req.Body).Decode(&batchRequest)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, "download", batchRequest.Operation)
|
||||
|
@ -267,7 +268,7 @@ func TestHTTPClientUpload(t *testing.T) {
|
|||
assert.Equal(t, MediaType, req.Header.Get("Accept"))
|
||||
|
||||
var batchRequest BatchRequest
|
||||
err := jsoniter.NewDecoder(req.Body).Decode(&batchRequest)
|
||||
err := json.NewDecoder(req.Body).Decode(&batchRequest)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, "upload", batchRequest.Operation)
|
||||
|
|
|
@ -12,9 +12,8 @@ import (
|
|||
"io"
|
||||
"net/http"
|
||||
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
// TransferAdapter represents an adapter for downloading/uploading LFS objects
|
||||
|
@ -65,7 +64,7 @@ func (a *BasicTransferAdapter) Upload(ctx context.Context, l *Link, p Pointer, r
|
|||
|
||||
// Verify calls the verify handler on the LFS server
|
||||
func (a *BasicTransferAdapter) Verify(ctx context.Context, l *Link, p Pointer) error {
|
||||
b, err := jsoniter.Marshal(p)
|
||||
b, err := json.Marshal(p)
|
||||
if err != nil {
|
||||
log.Error("Error encoding json: %v", err)
|
||||
return err
|
||||
|
@ -128,7 +127,7 @@ func handleErrorResponse(resp *http.Response) error {
|
|||
|
||||
func decodeReponseError(r io.Reader) (ErrorResponse, error) {
|
||||
var er ErrorResponse
|
||||
err := jsoniter.NewDecoder(r).Decode(&er)
|
||||
err := json.NewDecoder(r).Decode(&er)
|
||||
if err != nil {
|
||||
log.Error("Error decoding json: %v", err)
|
||||
}
|
||||
|
|
|
@ -13,7 +13,8 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
@ -49,7 +50,7 @@ func TestBasicTransferAdapter(t *testing.T) {
|
|||
assert.Equal(t, MediaType, req.Header.Get("Content-Type"))
|
||||
|
||||
var vp Pointer
|
||||
err := jsoniter.NewDecoder(req.Body).Decode(&vp)
|
||||
err := json.NewDecoder(req.Body).Decode(&vp)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, p.Oid, vp.Oid)
|
||||
assert.Equal(t, p.Size, vp.Size)
|
||||
|
@ -60,7 +61,7 @@ func TestBasicTransferAdapter(t *testing.T) {
|
|||
Message: "Object not found",
|
||||
}
|
||||
payload := new(bytes.Buffer)
|
||||
jsoniter.NewEncoder(payload).Encode(er)
|
||||
json.NewEncoder(payload).Encode(er)
|
||||
|
||||
return &http.Response{StatusCode: http.StatusNotFound, Body: ioutil.NopCloser(payload)}
|
||||
} else {
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"io"
|
||||
"net"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
)
|
||||
|
||||
type connWriter struct {
|
||||
|
@ -106,7 +106,6 @@ func NewConn() LoggerProvider {
|
|||
// 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 fmt.Errorf("Unable to parse JSON: %v", err)
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"io"
|
||||
"os"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
)
|
||||
|
||||
// CanColorStdout reports if we can color the Stdout
|
||||
|
@ -52,7 +52,6 @@ func NewConsoleLogger() LoggerProvider {
|
|||
// 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 fmt.Errorf("Unable to parse JSON: %v", err)
|
||||
|
|
|
@ -15,8 +15,8 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
// FileLogger implements LoggerProvider.
|
||||
|
@ -101,7 +101,6 @@ func NewFileLogger() LoggerProvider {
|
|||
// "rotate":true
|
||||
// }
|
||||
func (log *FileLogger) Init(config string) error {
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
if err := json.Unmarshal([]byte(config), log); err != nil {
|
||||
return fmt.Errorf("Unable to parse JSON: %v", err)
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
)
|
||||
|
||||
// Level is the level of the logger
|
||||
|
@ -104,7 +104,6 @@ func FromString(level string) Level {
|
|||
// 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)
|
||||
|
|
|
@ -8,7 +8,8 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
@ -17,7 +18,6 @@ type testLevel struct {
|
|||
}
|
||||
|
||||
func TestLevelMarshalUnmarshalJSON(t *testing.T) {
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
levelBytes, err := json.Marshal(testLevel{
|
||||
Level: INFO,
|
||||
})
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"net/smtp"
|
||||
"strings"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
)
|
||||
|
||||
type smtpWriter struct {
|
||||
|
@ -57,7 +57,6 @@ func NewSMTPLogger() LoggerProvider {
|
|||
// "level":LevelError
|
||||
// }
|
||||
func (log *SMTPLogger) Init(jsonconfig string) error {
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
err := json.Unmarshal([]byte(jsonconfig), log)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable to parse JSON: %v", err)
|
||||
|
|
|
@ -10,10 +10,10 @@ import (
|
|||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"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 {
|
||||
|
@ -296,7 +296,6 @@ func (*actionNotifier) NotifyPullRevieweDismiss(doer *models.User, review *model
|
|||
}
|
||||
|
||||
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)
|
||||
|
@ -368,7 +367,6 @@ func (a *actionNotifier) NotifyDeleteRef(doer *models.User, repo *models.Reposit
|
|||
}
|
||||
|
||||
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)
|
||||
|
|
|
@ -6,15 +6,14 @@ package private
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
// Git environment variables
|
||||
|
@ -88,7 +87,6 @@ func HookPreReceive(ctx context.Context, ownerName, repoName string, opts HookOp
|
|||
)
|
||||
req := newInternalRequest(ctx, 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)
|
||||
|
@ -115,7 +113,6 @@ func HookPostReceive(ctx context.Context, ownerName, repoName string, opts HookO
|
|||
req := newInternalRequest(ctx, 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()
|
||||
|
|
|
@ -12,8 +12,8 @@ import (
|
|||
"net/http"
|
||||
|
||||
"code.gitea.io/gitea/modules/httplib"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
func newRequest(ctx context.Context, url, method string) *httplib.Request {
|
||||
|
@ -30,7 +30,6 @@ type Response struct {
|
|||
|
||||
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()
|
||||
|
|
|
@ -10,8 +10,8 @@ import (
|
|||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
// Email structure holds a data for sending general emails
|
||||
|
@ -33,7 +33,6 @@ func SendEmail(ctx context.Context, subject, message string, to []string) (int,
|
|||
|
||||
req := newInternalRequest(ctx, reqURL, "POST")
|
||||
req = req.Header("Content-Type", "application/json")
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
jsonBytes, _ := json.Marshal(Email{
|
||||
Subject: subject,
|
||||
Message: message,
|
||||
|
|
|
@ -11,8 +11,8 @@ import (
|
|||
"net/url"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
// Shutdown calls the internal shutdown function
|
||||
|
@ -66,7 +66,6 @@ func FlushQueues(ctx context.Context, timeout time.Duration, nonBlocking bool) (
|
|||
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,
|
||||
|
@ -153,7 +152,6 @@ func AddLogger(ctx context.Context, group, name, mode string, config map[string]
|
|||
|
||||
req := newInternalRequest(ctx, reqURL, "POST")
|
||||
req = req.Header("Content-Type", "application/json")
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
jsonBytes, _ := json.Marshal(LoggerOptions{
|
||||
Group: group,
|
||||
Name: name,
|
||||
|
|
|
@ -11,8 +11,8 @@ import (
|
|||
"net/http"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
// RestoreParams structure holds a data for restore repository
|
||||
|
@ -30,7 +30,6 @@ func RestoreRepo(ctx context.Context, repoDir, ownerName, repoName string, units
|
|||
req := newInternalRequest(ctx, reqURL, "POST")
|
||||
req.SetTimeout(3*time.Second, 0) // since the request will spend much time, don't timeout
|
||||
req = req.Header("Content-Type", "application/json")
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
jsonBytes, _ := json.Marshal(RestoreParams{
|
||||
RepoDir: repoDir,
|
||||
OwnerName: ownerName,
|
||||
|
|
|
@ -11,8 +11,8 @@ import (
|
|||
"net/url"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
// KeyAndOwner is the response from ServNoCommand
|
||||
|
@ -35,7 +35,6 @@ func ServNoCommand(ctx context.Context, keyID int64) (*models.PublicKey, *models
|
|||
}
|
||||
|
||||
var keyAndOwner KeyAndOwner
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
if err := json.NewDecoder(resp.Body).Decode(&keyAndOwner); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
@ -91,7 +90,7 @@ func ServCommand(ctx context.Context, keyID int64, ownerName, repoName string, m
|
|||
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 {
|
||||
|
|
|
@ -7,7 +7,7 @@ package queue
|
|||
import (
|
||||
"reflect"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
)
|
||||
|
||||
// Mappable represents an interface that can MapTo another interface
|
||||
|
@ -20,8 +20,6 @@ type Mappable 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)) {
|
||||
return cfg, nil
|
||||
|
@ -48,7 +46,6 @@ func toConfig(exemplar, cfg interface{}) (interface{}, error) {
|
|||
if !ok {
|
||||
// hmm ... can we marshal it to json?
|
||||
var err error
|
||||
|
||||
configBytes, err = json.Marshal(cfg)
|
||||
ok = err == nil
|
||||
}
|
||||
|
@ -68,7 +65,6 @@ func toConfig(exemplar, cfg interface{}) (interface{}, error) {
|
|||
|
||||
// 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)
|
||||
|
@ -78,7 +74,6 @@ func unmarshalAs(bs []byte, exemplar interface{}) (data Data, err error) {
|
|||
} else {
|
||||
err = json.Unmarshal(bs, &data)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
var manager *Manager
|
||||
|
@ -110,7 +110,6 @@ func (m *Manager) Add(managed interface{},
|
|||
configuration,
|
||||
exemplar interface{}) int64 {
|
||||
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
cfg, _ := json.Marshal(configuration)
|
||||
mq := &ManagedQueue{
|
||||
Type: t,
|
||||
|
|
|
@ -10,8 +10,8 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
// ByteFIFOQueueConfiguration is the configuration for a ByteFIFOQueue
|
||||
|
@ -83,7 +83,6 @@ func (q *ByteFIFOQueue) PushFunc(data Data, fn func() error) error {
|
|||
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
|
||||
|
@ -309,7 +308,6 @@ func (q *ByteFIFOUniqueQueue) Has(data Data) (bool, error) {
|
|||
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
|
||||
|
|
|
@ -7,7 +7,8 @@ package queue
|
|||
import (
|
||||
"testing"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
@ -29,8 +30,6 @@ func TestToConfig(t *testing.T) {
|
|||
assert.True(t, ok)
|
||||
assert.NotEqual(t, cfg2, exemplar)
|
||||
assert.Equal(t, &cfg, &cfg2)
|
||||
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
cfgString, err := json.Marshal(cfg)
|
||||
assert.NoError(t, err)
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
func validType(t string) (Type, error) {
|
||||
|
@ -27,8 +27,6 @@ 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)
|
||||
|
|
|
@ -12,9 +12,9 @@ import (
|
|||
"net/url"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"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
|
||||
|
@ -50,8 +50,8 @@ func Verify(ctx context.Context, response string) (bool, error) {
|
|||
if err != nil {
|
||||
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)
|
||||
|
|
|
@ -8,12 +8,13 @@ import (
|
|||
"fmt"
|
||||
"sync"
|
||||
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
|
||||
"gitea.com/go-chi/session"
|
||||
couchbase "gitea.com/go-chi/session/couchbase"
|
||||
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.
|
||||
|
@ -25,7 +26,6 @@ type VirtualSessionProvider struct {
|
|||
// 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
|
||||
}
|
||||
|
|
|
@ -13,14 +13,13 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
|
||||
ini "gopkg.in/ini.v1"
|
||||
)
|
||||
|
||||
var filenameSuffix = ""
|
||||
|
||||
var descriptionLock = sync.RWMutex{}
|
||||
var logDescriptions = make(map[string]*LogDescription)
|
||||
|
||||
|
@ -203,8 +202,6 @@ func generateLogConfig(sec *ini.Section, name string, defaults defaultLogOptions
|
|||
}
|
||||
|
||||
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)
|
||||
|
|
|
@ -10,8 +10,8 @@ import (
|
|||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -65,8 +65,6 @@ func newSessionService() {
|
|||
default:
|
||||
SessionConfig.SameSite = http.SameSiteLaxMode
|
||||
}
|
||||
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
shadowConfig, err := json.Marshal(SessionConfig)
|
||||
if err != nil {
|
||||
log.Fatal("Can't shadow session config: %v", err)
|
||||
|
|
|
@ -24,11 +24,11 @@ import (
|
|||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/generate"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"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"
|
||||
|
@ -1116,7 +1116,6 @@ func MakeManifestData(appName string, appURL string, absoluteAssetURL string) []
|
|||
Icons []manifestIcon `json:"icons"`
|
||||
}
|
||||
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
bytes, err := json.Marshal(&manifestJSON{
|
||||
Name: appName,
|
||||
ShortName: appName,
|
||||
|
|
|
@ -7,7 +7,8 @@ package setting
|
|||
import (
|
||||
"testing"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
@ -28,6 +29,5 @@ func TestMakeAbsoluteAssetURL(t *testing.T) {
|
|||
|
||||
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))
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ package storage
|
|||
import (
|
||||
"reflect"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
)
|
||||
|
||||
// Mappable represents an interface that can MapTo another interface
|
||||
|
@ -20,8 +20,6 @@ type Mappable 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)) {
|
||||
return cfg, nil
|
||||
|
@ -48,7 +46,6 @@ func toConfig(exemplar, cfg interface{}) (interface{}, error) {
|
|||
if !ok {
|
||||
// hmm ... can we marshal it to json?
|
||||
var err error
|
||||
|
||||
configBytes, err = json.Marshal(cfg)
|
||||
ok = err == nil
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -132,14 +132,12 @@ type CreatePayload struct {
|
|||
|
||||
// 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
|
||||
}
|
||||
|
@ -183,7 +181,6 @@ type DeletePayload struct {
|
|||
|
||||
// JSONPayload implements Payload
|
||||
func (p *DeletePayload) JSONPayload() ([]byte, error) {
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
||||
|
@ -203,7 +200,6 @@ type ForkPayload struct {
|
|||
|
||||
// JSONPayload implements Payload
|
||||
func (p *ForkPayload) JSONPayload() ([]byte, error) {
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
||||
|
@ -230,7 +226,6 @@ type IssueCommentPayload struct {
|
|||
|
||||
// JSONPayload implements Payload
|
||||
func (p *IssueCommentPayload) JSONPayload() ([]byte, error) {
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
||||
|
@ -261,7 +256,6 @@ type ReleasePayload struct {
|
|||
|
||||
// JSONPayload implements Payload
|
||||
func (p *ReleasePayload) JSONPayload() ([]byte, error) {
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
||||
|
@ -287,14 +281,12 @@ type PushPayload struct {
|
|||
|
||||
// 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
|
||||
}
|
||||
|
@ -362,7 +354,6 @@ type IssuePayload struct {
|
|||
|
||||
// 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, "", " ")
|
||||
}
|
||||
|
||||
|
@ -398,7 +389,6 @@ type PullRequestPayload struct {
|
|||
|
||||
// JSONPayload FIXME
|
||||
func (p *PullRequestPayload) JSONPayload() ([]byte, error) {
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
||||
|
@ -435,6 +425,5 @@ type RepositoryPayload struct {
|
|||
|
||||
// JSONPayload JSON representation of the payload
|
||||
func (p *RepositoryPayload) JSONPayload() ([]byte, error) {
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ package structs
|
|||
import (
|
||||
"time"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
)
|
||||
|
||||
// User represents a user
|
||||
|
@ -56,7 +56,6 @@ type User struct {
|
|||
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"`
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/graceful"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/migrations"
|
||||
migration "code.gitea.io/gitea/modules/migrations/base"
|
||||
|
@ -20,7 +21,6 @@ import (
|
|||
"code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
func handleCreateError(owner *models.User, err error) error {
|
||||
|
@ -112,7 +112,6 @@ func runMigrateTask(t *models.Task) (err error) {
|
|||
Format: format,
|
||||
Args: args,
|
||||
}
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
bs, _ := json.Marshal(message)
|
||||
t.Message = string(bs)
|
||||
_ = t.UpdateCols("message")
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/graceful"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/migrations/base"
|
||||
"code.gitea.io/gitea/modules/queue"
|
||||
|
@ -18,7 +19,6 @@ import (
|
|||
"code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
// taskQueue is a global queue of tasks
|
||||
|
@ -85,8 +85,6 @@ func CreateMigrateTask(doer, u *models.User, opts base.MigrateOptions) (*models.
|
|||
return nil, err
|
||||
}
|
||||
opts.AuthToken = ""
|
||||
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
bs, err := json.Marshal(&opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -8,7 +8,6 @@ package templates
|
|||
import (
|
||||
"bytes"
|
||||
"container/list"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"html"
|
||||
|
@ -28,6 +27,7 @@ import (
|
|||
"code.gitea.io/gitea/modules/base"
|
||||
"code.gitea.io/gitea/modules/emoji"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/markup"
|
||||
"code.gitea.io/gitea/modules/repository"
|
||||
|
@ -38,7 +38,6 @@ import (
|
|||
"code.gitea.io/gitea/services/gitdiff"
|
||||
|
||||
"github.com/editorconfig/editorconfig-core-go/v2"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
// Used from static.go && dynamic.go
|
||||
|
@ -46,7 +45,6 @@ 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())
|
||||
|
@ -221,7 +219,7 @@ func NewFuncMap() []template.FuncMap {
|
|||
return fmt.Sprintf("%f", float64(adds)/(float64(adds)+float64(dels))*100)
|
||||
},
|
||||
"Json": func(in interface{}) string {
|
||||
out, err := jsonED.Marshal(in)
|
||||
out, err := json.Marshal(in)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
@ -847,7 +845,6 @@ func ActionContent2Commits(act Actioner) *repository.PushCommits {
|
|||
return push
|
||||
}
|
||||
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
if err := json.Unmarshal([]byte(act.GetContent()), push); err != nil {
|
||||
log.Error("json.Unmarshal:\n%s\nERROR: %v", act.GetContent(), err)
|
||||
}
|
||||
|
|
|
@ -12,11 +12,11 @@ import (
|
|||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/convert"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"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,7 +147,6 @@ 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"],
|
||||
|
@ -222,7 +221,6 @@ 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"],
|
||||
|
|
|
@ -11,11 +11,11 @@ import (
|
|||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"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,7 +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, private.Response{
|
||||
|
|
|
@ -10,12 +10,12 @@ import (
|
|||
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/graceful"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/private"
|
||||
"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,7 +130,6 @@ 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)
|
||||
|
|
|
@ -9,14 +9,13 @@ import (
|
|||
"net/http"
|
||||
|
||||
myCtx "code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/migrations"
|
||||
"code.gitea.io/gitea/modules/private"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
// RestoreRepo restore a repository from data
|
||||
func RestoreRepo(ctx *myCtx.PrivateContext) {
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
bs, err := ioutil.ReadAll(ctx.Req.Body)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, private.Response{
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/cron"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/process"
|
||||
"code.gitea.io/gitea/modules/queue"
|
||||
|
@ -28,7 +29,6 @@ import (
|
|||
"code.gitea.io/gitea/modules/web"
|
||||
"code.gitea.io/gitea/services/forms"
|
||||
"code.gitea.io/gitea/services/mailer"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
|
||||
"gitea.com/go-chi/session"
|
||||
)
|
||||
|
@ -275,7 +275,6 @@ 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)
|
||||
}
|
||||
|
|
|
@ -13,10 +13,10 @@ import (
|
|||
"code.gitea.io/gitea/modules/convert"
|
||||
"code.gitea.io/gitea/modules/eventsource"
|
||||
"code.gitea.io/gitea/modules/graceful"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/routers/web/user"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
// Events listens for events
|
||||
|
@ -103,7 +103,6 @@ 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)
|
||||
|
|
|
@ -16,6 +16,7 @@ import (
|
|||
"code.gitea.io/gitea/modules/charset"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/repofiles"
|
||||
repo_module "code.gitea.io/gitea/modules/repository"
|
||||
|
@ -26,7 +27,6 @@ import (
|
|||
"code.gitea.io/gitea/modules/web"
|
||||
"code.gitea.io/gitea/routers/utils"
|
||||
"code.gitea.io/gitea/services/forms"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -165,7 +165,6 @@ 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)
|
||||
}
|
||||
|
|
|
@ -17,13 +17,13 @@ import (
|
|||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/convert"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
"code.gitea.io/gitea/services/forms"
|
||||
"code.gitea.io/gitea/services/webhook"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -306,7 +306,6 @@ func DiscordHooksNewPost(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
meta, err := json.Marshal(&webhook.DiscordMeta{
|
||||
Username: form.Username,
|
||||
IconURL: form.IconURL,
|
||||
|
@ -402,7 +401,6 @@ func TelegramHooksNewPost(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
meta, err := json.Marshal(&webhook.TelegramMeta{
|
||||
BotToken: form.BotToken,
|
||||
ChatID: form.ChatID,
|
||||
|
@ -455,7 +453,6 @@ func MatrixHooksNewPost(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
meta, err := json.Marshal(&webhook.MatrixMeta{
|
||||
HomeserverURL: form.HomeserverURL,
|
||||
Room: form.RoomID,
|
||||
|
@ -560,7 +557,6 @@ func SlackHooksNewPost(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
meta, err := json.Marshal(&webhook.SlackMeta{
|
||||
Channel: strings.TrimSpace(form.Channel),
|
||||
Username: form.Username,
|
||||
|
@ -848,7 +844,6 @@ func SlackHooksEditPost(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
meta, err := json.Marshal(&webhook.SlackMeta{
|
||||
Channel: strings.TrimSpace(form.Channel),
|
||||
Username: form.Username,
|
||||
|
@ -894,7 +889,6 @@ func DiscordHooksEditPost(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
meta, err := json.Marshal(&webhook.DiscordMeta{
|
||||
Username: form.Username,
|
||||
IconURL: form.IconURL,
|
||||
|
@ -970,7 +964,7 @@ func TelegramHooksEditPost(ctx *context.Context) {
|
|||
ctx.HTML(http.StatusOK, orCtx.NewTemplate)
|
||||
return
|
||||
}
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
|
||||
meta, err := json.Marshal(&webhook.TelegramMeta{
|
||||
BotToken: form.BotToken,
|
||||
ChatID: form.ChatID,
|
||||
|
@ -1012,7 +1006,7 @@ func MatrixHooksEditPost(ctx *context.Context) {
|
|||
ctx.HTML(http.StatusOK, orCtx.NewTemplate)
|
||||
return
|
||||
}
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
|
||||
meta, err := json.Marshal(&webhook.MatrixMeta{
|
||||
HomeserverURL: form.HomeserverURL,
|
||||
Room: form.RoomID,
|
||||
|
|
|
@ -18,6 +18,7 @@ import (
|
|||
"code.gitea.io/gitea/modules/base"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
issue_indexer "code.gitea.io/gitea/modules/indexer/issues"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/markup"
|
||||
"code.gitea.io/gitea/modules/markup/markdown"
|
||||
|
@ -26,7 +27,6 @@ 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"
|
||||
|
@ -703,7 +703,6 @@ func buildIssueOverview(ctx *context.Context, unitType models.UnitType) {
|
|||
}
|
||||
|
||||
// Convert []int64 to string
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
reposParam, _ := json.Marshal(repoIDs)
|
||||
|
||||
ctx.Data["ReposParam"] = string(reposParam)
|
||||
|
|
|
@ -15,6 +15,7 @@ import (
|
|||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/base"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
|
@ -25,7 +26,6 @@ import (
|
|||
|
||||
"gitea.com/go-chi/binding"
|
||||
"github.com/golang-jwt/jwt"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -507,7 +507,7 @@ func OIDCKeys(ctx *context.Context) {
|
|||
}
|
||||
|
||||
ctx.Resp.Header().Set("Content-Type", "application/json")
|
||||
enc := jsoniter.NewEncoder(ctx.Resp)
|
||||
enc := json.NewEncoder(ctx.Resp)
|
||||
if err := enc.Encode(jwks); err != nil {
|
||||
log.Error("Failed to encode representation as json. Error: %v", err)
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
)
|
||||
|
||||
// TaskStatus returns task's status
|
||||
|
@ -26,7 +26,6 @@ func TaskStatus(ctx *context.Context) {
|
|||
|
||||
if task.Message != "" && task.Message[0] == '{' {
|
||||
// assume message is actually a translatable string
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
var translatableMessage models.TranslatableMessage
|
||||
if err := json.Unmarshal([]byte(message), &translatableMessage); err != nil {
|
||||
translatableMessage = models.TranslatableMessage{
|
||||
|
|
|
@ -8,10 +8,9 @@ import (
|
|||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/secret"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
// .____ ________ _____ __________
|
||||
|
@ -79,7 +78,6 @@ func (source *Source) ToDB() ([]byte, error) {
|
|||
return nil, err
|
||||
}
|
||||
source.BindPassword = ""
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
return json.Marshal(source)
|
||||
}
|
||||
|
||||
|
|
|
@ -6,8 +6,7 @@ package oauth2
|
|||
|
||||
import (
|
||||
"code.gitea.io/gitea/models"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
)
|
||||
|
||||
// ________ _____ __ .__ ________
|
||||
|
@ -37,7 +36,6 @@ func (source *Source) FromDB(bs []byte) error {
|
|||
|
||||
// ToDB exports an SMTPConfig to a serialized format.
|
||||
func (source *Source) ToDB() ([]byte, error) {
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
return json.Marshal(source)
|
||||
}
|
||||
|
||||
|
|
|
@ -6,8 +6,7 @@ package pam
|
|||
|
||||
import (
|
||||
"code.gitea.io/gitea/models"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
)
|
||||
|
||||
// __________ _____ _____
|
||||
|
@ -33,7 +32,6 @@ func (source *Source) FromDB(bs []byte) error {
|
|||
|
||||
// ToDB exports a PAMConfig to a serialized format.
|
||||
func (source *Source) ToDB() ([]byte, error) {
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
return json.Marshal(source)
|
||||
}
|
||||
|
||||
|
|
|
@ -6,8 +6,7 @@ package smtp
|
|||
|
||||
import (
|
||||
"code.gitea.io/gitea/models"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
)
|
||||
|
||||
// _________ __________________________
|
||||
|
@ -37,7 +36,6 @@ func (source *Source) FromDB(bs []byte) error {
|
|||
|
||||
// ToDB exports an SMTPConfig to a serialized format.
|
||||
func (source *Source) ToDB() ([]byte, error) {
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
return json.Marshal(source)
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ package sspi
|
|||
|
||||
import (
|
||||
"code.gitea.io/gitea/models"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
)
|
||||
|
||||
// _________ ___________________.___
|
||||
|
@ -32,7 +32,6 @@ func (cfg *Source) FromDB(bs []byte) error {
|
|||
|
||||
// ToDB exports an SSPIConfig to a serialized format.
|
||||
func (cfg *Source) ToDB() ([]byte, error) {
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
return json.Marshal(cfg)
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,9 @@ import (
|
|||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/highlight"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"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"
|
||||
|
@ -297,7 +298,7 @@ index 6961180..9ba1a00 100644
|
|||
t.Errorf("ParsePatch(%q) error = %v, wantErr %v", testcase.name, err, testcase.wantErr)
|
||||
return
|
||||
}
|
||||
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))
|
||||
|
|
|
@ -12,11 +12,11 @@ import (
|
|||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/convert"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
lfs_module "code.gitea.io/gitea/modules/lfs"
|
||||
"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"
|
||||
)
|
||||
|
||||
func handleLockListOut(ctx *context.Context, repo *models.Repository, lock *models.LFSLock, err error) {
|
||||
|
@ -159,7 +159,7 @@ func PostLockHandler(ctx *context.Context) {
|
|||
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)
|
||||
|
@ -293,7 +293,7 @@ func UnLockHandler(ctx *context.Context) {
|
|||
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)
|
||||
|
|
|
@ -17,12 +17,12 @@ import (
|
|||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
lfs_module "code.gitea.io/gitea/modules/lfs"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
|
||||
"github.com/golang-jwt/jwt"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
// requestContext contain variables from the HTTP request.
|
||||
|
@ -243,7 +243,7 @@ func BatchHandler(ctx *context.Context) {
|
|||
|
||||
ctx.Resp.Header().Set("Content-Type", lfs_module.MediaType)
|
||||
|
||||
enc := jsoniter.NewEncoder(ctx.Resp)
|
||||
enc := json.NewEncoder(ctx.Resp)
|
||||
if err := enc.Encode(respobj); err != nil {
|
||||
log.Error("Failed to encode representation as json. Error: %v", err)
|
||||
}
|
||||
|
@ -336,7 +336,7 @@ func VerifyHandler(ctx *context.Context) {
|
|||
func decodeJSON(req *http.Request, v interface{}) error {
|
||||
defer req.Body.Close()
|
||||
|
||||
dec := jsoniter.NewDecoder(req.Body)
|
||||
dec := json.NewDecoder(req.Body)
|
||||
return dec.Decode(v)
|
||||
}
|
||||
|
||||
|
@ -429,7 +429,7 @@ func writeStatusMessage(ctx *context.Context, status int, message string) {
|
|||
|
||||
er := lfs_module.ErrorResponse{Message: message}
|
||||
|
||||
enc := jsoniter.NewEncoder(ctx.Resp)
|
||||
enc := json.NewEncoder(ctx.Resp)
|
||||
if err := enc.Encode(er); err != nil {
|
||||
log.Error("Failed to encode error response as json. Error: %v", err)
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@ import (
|
|||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/graceful"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"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.
|
||||
|
@ -86,7 +86,6 @@ func NewPullRequest(repo *models.Repository, pull *models.Issue, labelIDs []int6
|
|||
data.CommitIDs = append(data.CommitIDs, e.Value.(*git.Commit).ID.String())
|
||||
}
|
||||
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
dataJSON, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -10,9 +10,9 @@ import (
|
|||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
dingtalk "github.com/lunny/dingtalk_webhook"
|
||||
)
|
||||
|
||||
|
@ -27,7 +27,6 @@ var (
|
|||
|
||||
// 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
|
||||
|
|
|
@ -12,10 +12,10 @@ import (
|
|||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"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 (
|
||||
|
@ -68,7 +68,6 @@ 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)
|
||||
}
|
||||
|
@ -99,7 +98,6 @@ var (
|
|||
|
||||
// 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
|
||||
|
@ -250,7 +248,6 @@ func GetDiscordPayload(p api.Payloader, event models.HookEventType, meta string)
|
|||
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())
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@ import (
|
|||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
type (
|
||||
|
@ -37,7 +37,6 @@ func newFeishuTextPayload(text string) *FeishuPayload {
|
|||
|
||||
// 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
|
||||
|
|
|
@ -15,10 +15,10 @@ import (
|
|||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"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
|
||||
|
@ -39,7 +39,6 @@ var messageTypeText = map[int]string{
|
|||
// 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)
|
||||
}
|
||||
|
@ -78,7 +77,6 @@ type MatrixPayloadSafe struct {
|
|||
|
||||
// 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
|
||||
|
@ -228,7 +226,6 @@ func GetMatrixPayload(p api.Payloader, event models.HookEventType, meta string)
|
|||
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())
|
||||
}
|
||||
|
@ -262,7 +259,6 @@ func getMessageBody(htmlText string) string {
|
|||
// The access_token is removed from t.PayloadContent
|
||||
func getMatrixHookRequest(w *models.Webhook, 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
|
||||
|
|
|
@ -10,8 +10,8 @@ import (
|
|||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
type (
|
||||
|
@ -57,7 +57,6 @@ 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
|
||||
|
|
|
@ -11,10 +11,10 @@ import (
|
|||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"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
|
||||
|
@ -28,7 +28,6 @@ type SlackMeta struct {
|
|||
// 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)
|
||||
}
|
||||
|
@ -58,7 +57,6 @@ type SlackAttachment struct {
|
|||
|
||||
// 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
|
||||
|
@ -279,7 +277,6 @@ func GetSlackPayload(p api.Payloader, event models.HookEventType, meta string) (
|
|||
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())
|
||||
}
|
||||
|
|
|
@ -10,10 +10,10 @@ import (
|
|||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"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 (
|
||||
|
@ -34,7 +34,6 @@ 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)
|
||||
}
|
||||
|
@ -50,7 +49,6 @@ func (t *TelegramPayload) JSONPayload() ([]byte, error) {
|
|||
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
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
package webhook
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue