Skip to content

Commit 9465ec3

Browse files
authored
Merge branch 'master' into master
2 parents 24ecaba + 374ff60 commit 9465ec3

File tree

123 files changed

+5768
-1003
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+5768
-1003
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ issues:
7070
- path: modules/log/
7171
linters:
7272
- errcheck
73-
- path: routers/routes/routes.go
73+
- path: routers/routes/macaron.go
7474
linters:
7575
- dupl
7676
- path: routers/api/v1/repo/issue_subscription.go

.stylelintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ rules:
1111
no-descending-specificity: null
1212
number-leading-zero: never
1313
rule-empty-line-before: null
14-
selector-pseudo-element-colon-notation: null
14+
selector-pseudo-element-colon-notation: double
1515
shorthand-property-no-redundant-values: true

cmd/web.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ import (
1919
"code.gitea.io/gitea/routers"
2020
"code.gitea.io/gitea/routers/routes"
2121

22-
"gitea.com/macaron/macaron"
23-
2422
context2 "github.com/gorilla/context"
2523
"github.com/unknwon/com"
2624
"github.com/urfave/cli"
@@ -135,9 +133,9 @@ func runWeb(ctx *cli.Context) error {
135133
return err
136134
}
137135
}
138-
m := routes.NewMacaron()
139-
routes.RegisterInstallRoute(m)
140-
err := listen(m, false)
136+
c := routes.NewChi()
137+
routes.RegisterInstallRoute(c)
138+
err := listen(c, false)
141139
select {
142140
case <-graceful.GetManager().IsShutdown():
143141
<-graceful.GetManager().Done()
@@ -168,10 +166,10 @@ func runWeb(ctx *cli.Context) error {
168166
}
169167
}
170168
// Set up Macaron
171-
m := routes.NewMacaron()
172-
routes.RegisterRoutes(m)
169+
c := routes.NewChi()
170+
routes.RegisterRoutes(c)
173171

174-
err := listen(m, true)
172+
err := listen(c, true)
175173
<-graceful.GetManager().Done()
176174
log.Info("PID: %d Gitea Web Finished", os.Getpid())
177175
log.Close()
@@ -212,7 +210,7 @@ func setPort(port string) error {
212210
return nil
213211
}
214212

215-
func listen(m *macaron.Macaron, handleRedirector bool) error {
213+
func listen(m http.Handler, handleRedirector bool) error {
216214
listenAddr := setting.HTTPAddr
217215
if setting.Protocol != setting.UnixSocket && setting.Protocol != setting.FCGIUnix {
218216
listenAddr = net.JoinHostPort(listenAddr, setting.HTTPPort)

contrib/pr/checkout.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ func runPR() {
117117
//routers.GlobalInit()
118118
external.RegisterParsers()
119119
markup.Init()
120-
m := routes.NewMacaron()
121-
routes.RegisterRoutes(m)
120+
c := routes.NewChi()
121+
routes.RegisterRoutes(c)
122122

123123
log.Printf("[PR] Ready for testing !\n")
124124
log.Printf("[PR] Login with user1, user2, user3, ... with pass: password\n")
@@ -138,7 +138,7 @@ func runPR() {
138138
*/
139139

140140
//Start the server
141-
http.ListenAndServe(":8080", context2.ClearHandler(m))
141+
http.ListenAndServe(":8080", context2.ClearHandler(c))
142142

143143
log.Printf("[PR] Cleaning up ...\n")
144144
/*

docs/content/doc/features/webhooks.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ if (empty($header_signature)) {
168168
$payload_signature = hash_hmac('sha256', $payload, $secret_key, false);
169169
170170
// check payload signature against header signature
171-
if ($header_signature != $payload_signature) {
171+
if ($header_signature !== $payload_signature) {
172172
error_log('FAILED - payload signature');
173173
exit();
174174
}

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ require (
3939
github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870 // indirect
4040
github.com/gliderlabs/ssh v0.3.1
4141
github.com/glycerine/go-unsnap-stream v0.0.0-20190901134440-81cf024a9e0a // indirect
42+
github.com/go-chi/chi v1.5.0
4243
github.com/go-enry/go-enry/v2 v2.5.2
4344
github.com/go-git/go-billy/v5 v5.0.0
4445
github.com/go-git/go-git/v5 v5.2.0

go.sum

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF
288288
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
289289
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
290290
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
291+
github.com/ethantkoenig/rupture v0.0.0-20181029165146-c3b3b810dc77 h1:ZLWiTTzTUBb0WEXUxobYI/RxULIzOoIP7pgfDd4p1cw=
291292
github.com/ethantkoenig/rupture v0.0.0-20181029165146-c3b3b810dc77/go.mod h1:MkKY/CB98aVE4VxO63X5vTQKUgcn+3XP15LMASe3lYs=
292293
github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51 h1:0JZ+dUmQeA8IIVUMzysrX4/AKuQwWhV2dYQuPZdvdSQ=
293294
github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64=
@@ -323,6 +324,8 @@ github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31 h1:gclg6gY70GLy
323324
github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24=
324325
github.com/go-asn1-ber/asn1-ber v1.5.1 h1:pDbRAunXzIUXfx4CB2QJFv5IuPiuoW+sWvr/Us009o8=
325326
github.com/go-asn1-ber/asn1-ber v1.5.1/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
327+
github.com/go-chi/chi v1.5.0 h1:2ZcJZozJ+rj6BA0c19ffBUGXEKAT/aOLOtQjD46vBRA=
328+
github.com/go-chi/chi v1.5.0/go.mod h1:REp24E+25iKvxgeTfHmdUoL5x15kBiDBlnIl5bCwe2k=
326329
github.com/go-enry/go-enry/v2 v2.5.2 h1:3f3PFAO6JitWkPi1GQ5/m6Xu4gNL1U5soJ8QaYqJ0YQ=
327330
github.com/go-enry/go-enry/v2 v2.5.2/go.mod h1:GVzIiAytiS5uT/QiuakK7TF1u4xDab87Y8V5EJRpsIQ=
328331
github.com/go-enry/go-oniguruma v1.2.1 h1:k8aAMuJfMrqm/56SG2lV9Cfti6tC4x8673aHCcBk+eo=
@@ -655,6 +658,7 @@ github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0f
655658
github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
656659
github.com/jackc/puddle v1.1.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
657660
github.com/jarcoal/httpmock v0.0.0-20180424175123-9c70cfe4a1da/go.mod h1:ks+b9deReOc7jgqp+e7LuFiCBH6Rm5hL32cLcEAArb4=
661+
github.com/jaytaylor/html2text v0.0.0-20200412013138-3577fbdbcff7 h1:g0fAGBisHaEQ0TRq1iBvemFRf+8AEWEmBESSiWB3Vsc=
658662
github.com/jaytaylor/html2text v0.0.0-20200412013138-3577fbdbcff7/go.mod h1:CVKlgaMiht+LXvHG173ujK6JUhZXKb2u/BQtjPDIvyk=
659663
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
660664
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
@@ -684,6 +688,7 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V
684688
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
685689
github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4=
686690
github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA=
691+
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
687692
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
688693
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd h1:Coekwdh0v2wtGp9Gmz1Ze3eVRAWJMLokvN3QjdzCHLY=
689694
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
@@ -1025,6 +1030,7 @@ github.com/spf13/viper v1.7.0 h1:xVKxvI7ouOI5I+U9s2eeiUfMaWBVoXA3AWskkrqK0VM=
10251030
github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
10261031
github.com/spf13/viper v1.7.1 h1:pM5oEahlgWv/WnHXpgbKz7iLIxRf65tye2Ci+XFK5sk=
10271032
github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
1033+
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf h1:pvbZ0lM0XWPBqUKqFU8cmavspvIl9nulOYwdy6IFRRo=
10281034
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf/go.mod h1:RJID2RhlZKId02nZ62WenDCkgHFerpIOmW0iT7GKmXM=
10291035
github.com/steveyen/gtreap v0.1.0 h1:CjhzTa274PyJLJuMZwIzCO1PfC00oRa8d1Kc78bFXJM=
10301036
github.com/steveyen/gtreap v0.1.0/go.mod h1:kl/5J7XbrOmlIbYIXdRHDDE5QxHqpk0cmkT7Z4dM9/Y=
@@ -1069,6 +1075,7 @@ github.com/unknwon/com v1.0.1/go.mod h1:tOOxU81rwgoCLoOVVPHb6T/wt8HZygqH5id+GNnl
10691075
github.com/unknwon/i18n v0.0.0-20190805065654-5c6446a380b6/go.mod h1:+5rDk6sDGpl3azws3O+f+GpFSyN9GVr0K8cvQLQM2ZQ=
10701076
github.com/unknwon/i18n v0.0.0-20200823051745-09abd91c7f2c h1:679/gJXwrsHC3RATr0YYjZvDMJPYN7W9FGSGNoLmKxM=
10711077
github.com/unknwon/i18n v0.0.0-20200823051745-09abd91c7f2c/go.mod h1:+5rDk6sDGpl3azws3O+f+GpFSyN9GVr0K8cvQLQM2ZQ=
1078+
github.com/unknwon/paginater v0.0.0-20200328080006-042474bd0eae h1:ihaXiJkaca54IaCSnEXtE/uSZOmPxKZhDfVLrzZLFDs=
10721079
github.com/unknwon/paginater v0.0.0-20200328080006-042474bd0eae/go.mod h1:1fdkY6xxl6ExVs2QFv7R0F5IRZHKA8RahhB9fMC9RvM=
10731080
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
10741081
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=

integrations/create_no_session_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ func TestSessionFileCreation(t *testing.T) {
5858
oldSessionConfig := setting.SessionConfig.ProviderConfig
5959
defer func() {
6060
setting.SessionConfig.ProviderConfig = oldSessionConfig
61-
mac = routes.NewMacaron()
62-
routes.RegisterRoutes(mac)
61+
c = routes.NewChi()
62+
routes.RegisterRoutes(c)
6363
}()
6464

6565
var config session.Options
@@ -83,8 +83,8 @@ func TestSessionFileCreation(t *testing.T) {
8383

8484
setting.SessionConfig.ProviderConfig = string(newConfigBytes)
8585

86-
mac = routes.NewMacaron()
87-
routes.RegisterRoutes(mac)
86+
c = routes.NewChi()
87+
routes.RegisterRoutes(c)
8888

8989
t.Run("NoSessionOnViewIssue", func(t *testing.T) {
9090
defer PrintCurrentTest(t)()

integrations/git_helper_for_declarative_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func onGiteaRun(t *testing.T, callback func(*testing.T, *url.URL), prepare ...bo
8282
defer prepareTestEnv(t, 1)()
8383
}
8484
s := http.Server{
85-
Handler: mac,
85+
Handler: c,
8686
}
8787

8888
u, err := url.Parse(setting.AppURL)

integrations/integration_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ import (
3434
"code.gitea.io/gitea/routers"
3535
"code.gitea.io/gitea/routers/routes"
3636

37-
"gitea.com/macaron/macaron"
3837
"github.com/PuerkitoBio/goquery"
38+
"github.com/go-chi/chi"
3939
"github.com/stretchr/testify/assert"
4040
"github.com/unknwon/com"
4141
)
4242

43-
var mac *macaron.Macaron
43+
var c chi.Router
4444

4545
type NilResponseRecorder struct {
4646
httptest.ResponseRecorder
@@ -67,8 +67,8 @@ func TestMain(m *testing.M) {
6767
defer cancel()
6868

6969
initIntegrationTest()
70-
mac = routes.NewMacaron()
71-
routes.RegisterRoutes(mac)
70+
c = routes.NewChi()
71+
routes.RegisterRoutes(c)
7272

7373
// integration test settings...
7474
if setting.Cfg != nil {
@@ -404,7 +404,7 @@ const NoExpectedStatus = -1
404404
func MakeRequest(t testing.TB, req *http.Request, expectedStatus int) *httptest.ResponseRecorder {
405405
t.Helper()
406406
recorder := httptest.NewRecorder()
407-
mac.ServeHTTP(recorder, req)
407+
c.ServeHTTP(recorder, req)
408408
if expectedStatus != NoExpectedStatus {
409409
if !assert.EqualValues(t, expectedStatus, recorder.Code,
410410
"Request: %s %s", req.Method, req.URL.String()) {
@@ -417,7 +417,7 @@ func MakeRequest(t testing.TB, req *http.Request, expectedStatus int) *httptest.
417417
func MakeRequestNilResponseRecorder(t testing.TB, req *http.Request, expectedStatus int) *NilResponseRecorder {
418418
t.Helper()
419419
recorder := NewNilResponseRecorder()
420-
mac.ServeHTTP(recorder, req)
420+
c.ServeHTTP(recorder, req)
421421
if expectedStatus != NoExpectedStatus {
422422
if !assert.EqualValues(t, expectedStatus, recorder.Code,
423423
"Request: %s %s", req.Method, req.URL.String()) {

integrations/oauth_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
package integrations
66

77
import (
8+
"bytes"
89
"encoding/json"
10+
"io/ioutil"
911
"testing"
1012

1113
"code.gitea.io/gitea/modules/setting"
@@ -233,11 +235,21 @@ func TestRefreshTokenInvalidation(t *testing.T) {
233235
"redirect_uri": "a",
234236
"refresh_token": parsed.RefreshToken,
235237
})
238+
// tip: Why this changed, because macaron will set req.Body back when consume the req but chi will not.
239+
bs, err := ioutil.ReadAll(refreshReq.Body)
240+
assert.NoError(t, err)
241+
242+
refreshReq.Body = ioutil.NopCloser(bytes.NewReader(bs))
236243
MakeRequest(t, refreshReq, 200)
244+
245+
refreshReq.Body = ioutil.NopCloser(bytes.NewReader(bs))
237246
MakeRequest(t, refreshReq, 200)
238247

239248
// test with invalidation
240249
setting.OAuth2.InvalidateRefreshTokens = true
250+
refreshReq.Body = ioutil.NopCloser(bytes.NewReader(bs))
241251
MakeRequest(t, refreshReq, 200)
252+
253+
refreshReq.Body = ioutil.NopCloser(bytes.NewReader(bs))
242254
MakeRequest(t, refreshReq, 400)
243255
}

models/issue_reaction.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ import (
1717

1818
// Reaction represents a reactions on issues and comments.
1919
type Reaction struct {
20-
ID int64 `xorm:"pk autoincr"`
21-
Type string `xorm:"INDEX UNIQUE(s) NOT NULL"`
22-
IssueID int64 `xorm:"INDEX UNIQUE(s) NOT NULL"`
23-
CommentID int64 `xorm:"INDEX UNIQUE(s)"`
24-
UserID int64 `xorm:"INDEX UNIQUE(s) NOT NULL"`
25-
OriginalAuthorID int64 `xorm:"INDEX UNIQUE(s) NOT NULL DEFAULT(0)"`
26-
OriginalAuthor string
20+
ID int64 `xorm:"pk autoincr"`
21+
Type string `xorm:"INDEX UNIQUE(s) NOT NULL"`
22+
IssueID int64 `xorm:"INDEX UNIQUE(s) NOT NULL"`
23+
CommentID int64 `xorm:"INDEX UNIQUE(s)"`
24+
UserID int64 `xorm:"INDEX UNIQUE(s) NOT NULL"`
25+
OriginalAuthorID int64 `xorm:"INDEX UNIQUE(s) NOT NULL DEFAULT(0)"`
26+
OriginalAuthor string `xorm:"INDEX UNIQUE(s)"`
2727
User *User `xorm:"-"`
2828
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
2929
}

models/migrations/migrations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ var migrations = []Migration{
252252
NewMigration("ensure repo topics are up-to-date", fixRepoTopics),
253253
// v158 -> v159
254254
NewMigration("code comment replies should have the commitID of the review they are replying to", updateCodeCommentReplies),
255+
// v159 -> v160
256+
NewMigration("update reactions constraint", updateReactionConstraint),
255257
}
256258

257259
// GetCurrentDBVersion returns the current db version

models/migrations/v156.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ func fixPublisherIDforTagReleases(x *xorm.Engine) error {
5555
var (
5656
repo *Repository
5757
gitRepo *git.Repository
58+
user *User
5859
)
5960
defer func() {
6061
if gitRepo != nil {
@@ -69,7 +70,7 @@ func fixPublisherIDforTagReleases(x *xorm.Engine) error {
6970
}
7071

7172
if err := sess.Limit(batchSize, start).
72-
Where("publisher_id = 0").
73+
Where("publisher_id = 0 OR publisher_id is null").
7374
Asc("repo_id", "id").Where("is_tag=?", true).
7475
Find(&releases); err != nil {
7576
return err
@@ -117,17 +118,21 @@ func fixPublisherIDforTagReleases(x *xorm.Engine) error {
117118
return fmt.Errorf("GetTagCommit: %v", err)
118119
}
119120

120-
u := new(User)
121-
exists, err := sess.Where("email=?", commit.Author.Email).Get(u)
122-
if err != nil {
123-
return err
121+
if user == nil || !strings.EqualFold(user.Email, commit.Author.Email) {
122+
user = new(User)
123+
_, err = sess.Where("email=?", commit.Author.Email).Get(user)
124+
if err != nil {
125+
return err
126+
}
127+
128+
user.Email = commit.Author.Email
124129
}
125130

126-
if !exists {
131+
if user.ID <= 0 {
127132
continue
128133
}
129134

130-
release.PublisherID = u.ID
135+
release.PublisherID = user.ID
131136
if _, err := sess.ID(release.ID).Cols("publisher_id").Update(release); err != nil {
132137
return err
133138
}

models/migrations/v159.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2020 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package migrations
6+
7+
import (
8+
"code.gitea.io/gitea/modules/timeutil"
9+
10+
"xorm.io/xorm"
11+
)
12+
13+
func updateReactionConstraint(x *xorm.Engine) error {
14+
// Reaction represents a reactions on issues and comments.
15+
type Reaction struct {
16+
ID int64 `xorm:"pk autoincr"`
17+
Type string `xorm:"INDEX UNIQUE(s) NOT NULL"`
18+
IssueID int64 `xorm:"INDEX UNIQUE(s) NOT NULL"`
19+
CommentID int64 `xorm:"INDEX UNIQUE(s)"`
20+
UserID int64 `xorm:"INDEX UNIQUE(s) NOT NULL"`
21+
OriginalAuthorID int64 `xorm:"INDEX UNIQUE(s) NOT NULL DEFAULT(0)"`
22+
OriginalAuthor string `xorm:"INDEX UNIQUE(s)"`
23+
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
24+
}
25+
26+
sess := x.NewSession()
27+
defer sess.Close()
28+
29+
if err := sess.Begin(); err != nil {
30+
return err
31+
}
32+
33+
if err := recreateTable(sess, &Reaction{}); err != nil {
34+
return err
35+
}
36+
37+
return sess.Commit()
38+
}

modules/auth/repo_form.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ func ParseRemoteAddr(remoteAddr, authUsername, authPassword string, user *models
102102
u.User = url.UserPassword(authUsername, authPassword)
103103
}
104104
remoteAddr = u.String()
105+
if u.Scheme == "git" && u.Port() != "" && (strings.Contains(remoteAddr, "%0d") || strings.Contains(remoteAddr, "%0a")) {
106+
return "", models.ErrInvalidCloneAddr{IsURLError: true}
107+
}
105108
} else if !user.CanImportLocal() {
106109
return "", models.ErrInvalidCloneAddr{IsPermissionDenied: true}
107110
} else if !com.IsDir(remoteAddr) {

0 commit comments

Comments
 (0)