Skip to content

Commit 607f740

Browse files
committed
Update to latest Gitea 1.16
2 parents 686bb1b + 4384b85 commit 607f740

File tree

16 files changed

+70
-22
lines changed

16 files changed

+70
-22
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ require (
8585
github.com/mrjones/oauth v0.0.0-20190623134757-126b35219450 // indirect
8686
github.com/msteinert/pam v0.0.0-20201130170657-e61372126161
8787
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
88-
github.com/niklasfasching/go-org v1.6.0
88+
github.com/niklasfasching/go-org v1.6.1
8989
github.com/olekukonko/tablewriter v0.0.5 // indirect
9090
github.com/oliamb/cutter v0.2.2
9191
github.com/olivere/elastic/v7 v7.0.25

go.sum

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
202202
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
203203
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
204204
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
205-
github.com/chaseadamsio/goorgeous v2.0.0+incompatible/go.mod h1:6QaC0vFoKWYDth94dHFNgRT2YkT5FHdQp/Yx15aAAi0=
206205
github.com/chi-middleware/proxy v1.1.1 h1:4HaXUp8o2+bhHr1OhVy+VjN0+L7/07JDcn6v7YrTjrQ=
207206
github.com/chi-middleware/proxy v1.1.1/go.mod h1:jQwMEJct2tz9VmtCELxvnXoMfa+SOdikvbVJVHv/M+0=
208207
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
@@ -913,8 +912,8 @@ github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OS
913912
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
914913
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
915914
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
916-
github.com/niklasfasching/go-org v1.6.0 h1:NCWpmDDNjHNsrei6VmnYXzOiyZUxV8LVU19REGQ8dKA=
917-
github.com/niklasfasching/go-org v1.6.0/go.mod h1:gSHyFcAbr2thIpfljLsP/BB8uwAMyooq6ydIrUDdOCs=
915+
github.com/niklasfasching/go-org v1.6.1 h1:vaGWr6TPqprkAbOJ/+E08mgZxsLM0SCOqWo9D5plj4U=
916+
github.com/niklasfasching/go-org v1.6.1/go.mod h1:3m8LIjGNz0ijv6UQzCpDl/bORThFI80/1xz2r1GgIT0=
918917
github.com/nwaples/rardecode v1.1.0 h1:vSxaY8vQhOcVr4mm5e8XllHWTiM4JF507A0Katqw7MQ=
919918
github.com/nwaples/rardecode v1.1.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0=
920919
github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
@@ -1033,9 +1032,8 @@ github.com/rs/xid v1.3.0 h1:6NjYksEUlhurdVehpc7S7dk6DAmcKv8V9gG0FsVN2U4=
10331032
github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
10341033
github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
10351034
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
1035+
github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo=
10361036
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
1037-
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=
1038-
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
10391037
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
10401038
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
10411039
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=

integrations/api_repo_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,6 @@ func TestAPIRepoTransfer(t *testing.T) {
445445
expectedStatus int
446446
}{
447447
// Disclaimer for test story: "user1" is an admin, "user2" is normal user and part of in owner team of org "user3"
448-
449448
// Transfer to a user with teams in another org should fail
450449
{ctxUserID: 1, newOwner: "user3", teams: &[]int64{5}, expectedStatus: http.StatusForbidden},
451450
// Transfer to a user with non-existent team IDs should fail

models/migrations/migrations.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ type Version struct {
6161
// update minDBVersion accordingly
6262
var migrations = []Migration{
6363
// Gitea 1.5.0 ends at v69
64-
6564
// v70 -> v71
6665
NewMigration("add issue_dependencies", addIssueDependencies),
6766
// v71 -> v72

models/migrations/v210.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
"strings"
1212

1313
"code.gitea.io/gitea/modules/timeutil"
14-
"github.com/tstranex/u2f"
1514

15+
"github.com/tstranex/u2f"
1616
"xorm.io/xorm"
1717
"xorm.io/xorm/schemas"
1818
)

models/migrations/v210_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"testing"
99

1010
"code.gitea.io/gitea/modules/timeutil"
11+
1112
"github.com/stretchr/testify/assert"
1213
"xorm.io/xorm/schemas"
1314
)

models/user/user.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ func updateUser(ctx context.Context, u *User, changePrimaryEmail bool, cols ...s
886886
}); err != nil {
887887
return err
888888
}
889-
} else { // check if primary email in email_address table
889+
} else if !u.IsOrganization() { // check if primary email in email_address table
890890
primaryEmailExist, err := e.Where("uid=? AND is_primary=?", u.ID, true).Exist(&EmailAddress{})
891891
if err != nil {
892892
return err

modules/charset/escape.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ func EscapeControlBytes(text []byte) (EscapeStatus, []byte) {
6363
func EscapeControlReader(text io.Reader, output io.Writer) (escaped EscapeStatus, err error) {
6464
buf := make([]byte, 4096)
6565
readStart := 0
66+
runeCount := 0
6667
var n int
6768
var writePos int
6869

@@ -79,6 +80,8 @@ readingloop:
7980

8081
for i < len(bs) {
8182
r, size := utf8.DecodeRune(bs[i:])
83+
runeCount++
84+
8285
// Now handle the codepoints
8386
switch {
8487
case r == utf8.RuneError:
@@ -113,6 +116,8 @@ readingloop:
113116
lineHasRTLScript = false
114117
lineHasLTRScript = false
115118

119+
case runeCount == 1 && r == 0xFEFF: // UTF BOM
120+
// the first BOM is safe
116121
case r == '\r' || r == '\t' || r == ' ':
117122
// These are acceptable control characters and space characters
118123
case unicode.IsSpace(r):
@@ -144,7 +149,8 @@ readingloop:
144149
return
145150
}
146151
writePos = i + size
147-
case unicode.Is(unicode.C, r):
152+
// 65279 == BOM rune.
153+
case unicode.Is(unicode.C, r) && r != rune(65279):
148154
escaped.Escaped = true
149155
escaped.HasControls = true
150156
if writePos < i {

modules/charset/escape_test.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ then resh (ר), and finally heh (ה) (which should appear leftmost).`,
129129
"\n" + `if access_level != "user<span class="escaped-code-point" data-escaped="[U+202E]"><span class="char">` + "\u202e" + `</span></span> <span class="escaped-code-point" data-escaped="[U+2066]"><span class="char">` + "\u2066" + `</span></span>// Check if admin<span class="escaped-code-point" data-escaped="[U+2069]"><span class="char">` + "\u2069" + `</span></span> <span class="escaped-code-point" data-escaped="[U+2066]"><span class="char">` + "\u2066" + `</span></span>" {` + "\n",
130130
status: EscapeStatus{Escaped: true, HasBIDI: true, BadBIDI: true, HasLTRScript: true, HasRTLScript: true},
131131
},
132+
{
133+
// UTF-8/16/32 all use the same codepoint for BOM
134+
// Gitea could read UTF-16/32 content and convert into UTF-8 internally then render it, so we only process UTF-8 internally
135+
name: "UTF BOM",
136+
text: "\xef\xbb\xbftest",
137+
result: "\xef\xbb\xbftest",
138+
status: EscapeStatus{HasLTRScript: true},
139+
},
132140
}
133141

134142
func TestEscapeControlString(t *testing.T) {
@@ -163,19 +171,27 @@ func TestEscapeControlReader(t *testing.T) {
163171
// lets add some control characters to the tests
164172
tests := make([]escapeControlTest, 0, len(escapeControlTests)*3)
165173
copy(tests, escapeControlTests)
174+
175+
// if there is a BOM, we should keep the BOM
176+
addPrefix := func(prefix, s string) string {
177+
if strings.HasPrefix(s, "\xef\xbb\xbf") {
178+
return s[:3] + prefix + s[3:]
179+
}
180+
return prefix + s
181+
}
166182
for _, test := range escapeControlTests {
167183
test.name += " (+Control)"
168-
test.text = "\u001E" + test.text
169-
test.result = `<span class="escaped-code-point" data-escaped="[U+001E]"><span class="char">` + "\u001e" + `</span></span>` + test.result
184+
test.text = addPrefix("\u001E", test.text)
185+
test.result = addPrefix(`<span class="escaped-code-point" data-escaped="[U+001E]"><span class="char">`+"\u001e"+`</span></span>`, test.result)
170186
test.status.Escaped = true
171187
test.status.HasControls = true
172188
tests = append(tests, test)
173189
}
174190

175191
for _, test := range escapeControlTests {
176192
test.name += " (+Mark)"
177-
test.text = "\u0300" + test.text
178-
test.result = `<span class="escaped-code-point" data-escaped="[U+0300]"><span class="char">` + "\u0300" + `</span></span>` + test.result
193+
test.text = addPrefix("\u0300", test.text)
194+
test.result = addPrefix(`<span class="escaped-code-point" data-escaped="[U+0300]"><span class="char">`+"\u0300"+`</span></span>`, test.result)
179195
test.status.Escaped = true
180196
test.status.HasMarks = true
181197
tests = append(tests, test)

modules/context/org.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,23 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
129129

130130
// Team.
131131
if ctx.Org.IsMember {
132+
shouldSeeAllTeams := false
132133
if ctx.Org.IsOwner {
134+
shouldSeeAllTeams = true
135+
} else {
136+
teams, err := org.GetUserTeams(ctx.User.ID)
137+
if err != nil {
138+
ctx.ServerError("GetUserTeams", err)
139+
return
140+
}
141+
for _, team := range teams {
142+
if team.IncludesAllRepositories && team.AccessMode >= perm.AccessModeAdmin {
143+
shouldSeeAllTeams = true
144+
break
145+
}
146+
}
147+
}
148+
if shouldSeeAllTeams {
133149
ctx.Org.Teams, err = org.LoadTeams()
134150
if err != nil {
135151
ctx.ServerError("LoadTeams", err)

modules/context/repo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
911911

912912
if refType == RepoRefLegacy {
913913
// redirect from old URL scheme to new URL scheme
914-
prefix := strings.TrimPrefix(setting.AppSubURL+strings.TrimSuffix(ctx.Req.URL.Path, ctx.Params("*")), ctx.Repo.RepoLink)
914+
prefix := strings.TrimPrefix(setting.AppSubURL+strings.ToLower(strings.TrimSuffix(ctx.Req.URL.Path, ctx.Params("*"))), strings.ToLower(ctx.Repo.RepoLink))
915915

916916
ctx.Redirect(path.Join(
917917
ctx.Repo.RepoLink,

modules/markup/html.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ var issueFullPatternOnce sync.Once
9999
func getIssueFullPattern() *regexp.Regexp {
100100
issueFullPatternOnce.Do(func() {
101101
issueFullPattern = regexp.MustCompile(regexp.QuoteMeta(setting.AppURL) +
102-
`\w+/\w+/(?:issues|pulls)/((?:\w{1,10}-)?[1-9][0-9]*)([\?|#](\S+)?)?\b`)
102+
`[\w_.-]+/[\w_.-]+/(?:issues|pulls)/((?:\w{1,10}-)?[1-9][0-9]*)([\?|#](\S+)?)?\b`)
103103
})
104104
return issueFullPattern
105105
}

modules/markup/html_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ func TestRender_CrossReferences(t *testing.T) {
9595
test(
9696
"/home/gitea/go-gitea/gitea#12345",
9797
`<p>/home/gitea/go-gitea/gitea#12345</p>`)
98+
test(
99+
util.URLJoin(TestAppURL, "gogitea", "gitea", "issues", "12345"),
100+
`<p><a href="`+util.URLJoin(TestAppURL, "gogitea", "gitea", "issues", "12345")+`" class="ref-issue" rel="nofollow">gogitea/gitea#12345</a></p>`)
101+
test(
102+
util.URLJoin(TestAppURL, "go-gitea", "gitea", "issues", "12345"),
103+
`<p><a href="`+util.URLJoin(TestAppURL, "go-gitea", "gitea", "issues", "12345")+`" class="ref-issue" rel="nofollow">go-gitea/gitea#12345</a></p>`)
104+
test(
105+
util.URLJoin(TestAppURL, "gogitea", "some-repo-name", "issues", "12345"),
106+
`<p><a href="`+util.URLJoin(TestAppURL, "gogitea", "some-repo-name", "issues", "12345")+`" class="ref-issue" rel="nofollow">gogitea/some-repo-name#12345</a></p>`)
98107
}
99108

100109
func TestMisc_IsSameDomain(t *testing.T) {

routers/api/v1/admin/adopt.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,13 @@ func ListUnadoptedRepositories(ctx *context.APIContext) {
4343
// "$ref": "#/responses/forbidden"
4444

4545
listOptions := utils.GetListOptions(ctx)
46+
if listOptions.Page == 0 {
47+
listOptions.Page = 1
48+
}
4649
repoNames, count, err := repo_service.ListUnadoptedRepositories(ctx.FormString("query"), &listOptions)
4750
if err != nil {
4851
ctx.InternalServerError(err)
52+
return
4953
}
5054

5155
ctx.SetTotalCountHeader(int64(count))

templates/org/team/members.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<div class="ui bottom attached table segment members">
2727
{{range .Team.Members}}
2828
<div class="item">
29-
{{if and $.IsOrganizationOwner (not (eq $.SignedUser.ID .ID))}}
29+
{{if and $.IsOrganizationOwner (not (and ($.Team.IsOwnerTeam) (eq (len $.Team.Members) 1)))}}
3030
<form>
3131
<button class="ui red button delete-button right" data-modal-id="remove-team-member"
3232
data-url="{{$.OrgLink}}/teams/{{$.Team.LowerName | PathEscape}}/action/remove" data-datauid="{{.ID}}"

templates/org/team/sidebar.tmpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@
4444
</ul>
4545
{{if (eq .Team.AccessMode 2)}}
4646
<h3>{{.i18n.Tr "org.settings.permission"}}</h3>
47-
{{.i18n.Tr "org.teams.write_permission_desc"}}
47+
{{.i18n.Tr "org.teams.write_permission_desc" | Str2html}}
4848
{{else if (eq .Team.AccessMode 3)}}
4949
<h3>{{.i18n.Tr "org.settings.permission"}}</h3>
50-
{{.i18n.Tr "org.teams.admin_permission_desc"}}
50+
{{.i18n.Tr "org.teams.admin_permission_desc" | Str2html}}
5151
{{else}}
5252
<table class="ui table">
5353
<thead>
@@ -74,8 +74,8 @@
7474
</tbody>
7575
</table>
7676
{{end}}
77-
{{end}}
78-
</div>
77+
</div>
78+
{{end}}
7979
</div>
8080
{{if .IsOrganizationOwner}}
8181
<div class="ui bottom attached segment">

0 commit comments

Comments
 (0)