Skip to content

Commit a9f06a7

Browse files
authored
Merge branch 'main' into improve-template-eval
2 parents 7b13dfc + 8803343 commit a9f06a7

File tree

9 files changed

+112
-18
lines changed

9 files changed

+112
-18
lines changed

models/fixtures/action.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,12 @@
6464
repo_id: 1700 # dangling intentional
6565
is_private: false
6666
created_unix: 1603011541
67+
68+
- id: 9
69+
user_id: 34
70+
op_type: 12 # close issue
71+
act_user_id: 34
72+
repo_id: 1 # public
73+
is_private: false
74+
created_unix: 1680454039
75+
content: '4|' # issueId 5

models/fixtures/user.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,3 +1220,41 @@
12201220
repo_admin_change_team_access: false
12211221
theme: ""
12221222
keep_activity_private: false
1223+
1224+
-
1225+
id: 34
1226+
lower_name: the_34-user.with.all.allowedchars
1227+
name: the_34-user.with.all.allowedChars
1228+
full_name: the_1-user.with.all.allowedChars
1229+
description: 'some [commonmark](https://commonmark.org/)!'
1230+
1231+
keep_email_private: false
1232+
email_notifications_preference: enabled
1233+
passwd: ZogKvWdyEx:password
1234+
passwd_hash_algo: dummy
1235+
must_change_password: false
1236+
login_source: 0
1237+
login_name: the_34-user.with.all.allowedchars
1238+
type: 0
1239+
salt: ZogKvWdyEx
1240+
max_repo_creation: -1
1241+
is_active: true
1242+
is_admin: false
1243+
is_restricted: false
1244+
allow_git_hook: false
1245+
allow_import_local: false
1246+
allow_create_organization: false
1247+
prohibit_login: false
1248+
avatar: avatar34
1249+
avatar_email: [email protected]
1250+
use_custom_avatar: true
1251+
num_followers: 0
1252+
num_following: 0
1253+
num_stars: 0
1254+
num_repos: 0
1255+
num_teams: 0
1256+
num_members: 0
1257+
visibility: 0
1258+
repo_admin_change_team_access: false
1259+
theme: ""
1260+
keep_activity_private: false

models/user/user_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@ func TestSearchUsers(t *testing.T) {
9999
}
100100

101101
testUserSuccess(&user_model.SearchUserOptions{OrderBy: "id ASC", ListOptions: db.ListOptions{Page: 1}},
102-
[]int64{1, 2, 4, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 21, 24, 27, 28, 29, 30, 32})
102+
[]int64{1, 2, 4, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 21, 24, 27, 28, 29, 30, 32, 34})
103103

104104
testUserSuccess(&user_model.SearchUserOptions{ListOptions: db.ListOptions{Page: 1}, IsActive: util.OptionalBoolFalse},
105105
[]int64{9})
106106

107107
testUserSuccess(&user_model.SearchUserOptions{OrderBy: "id ASC", ListOptions: db.ListOptions{Page: 1}, IsActive: util.OptionalBoolTrue},
108-
[]int64{1, 2, 4, 5, 8, 10, 11, 12, 13, 14, 15, 16, 18, 20, 21, 24, 27, 28, 29, 30, 32})
108+
[]int64{1, 2, 4, 5, 8, 10, 11, 12, 13, 14, 15, 16, 18, 20, 21, 24, 27, 28, 29, 30, 32, 34})
109109

110110
testUserSuccess(&user_model.SearchUserOptions{Keyword: "user1", OrderBy: "id ASC", ListOptions: db.ListOptions{Page: 1}, IsActive: util.OptionalBoolTrue},
111111
[]int64{1, 10, 11, 12, 13, 14, 15, 16, 18})

modules/context/repo.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,11 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
537537
ctx.Data["RepoLink"] = ctx.Repo.RepoLink
538538
ctx.Data["RepoRelPath"] = ctx.Repo.Owner.Name + "/" + ctx.Repo.Repository.Name
539539

540+
if setting.EnableFeed {
541+
ctx.Data["EnableFeed"] = true
542+
ctx.Data["FeedURL"] = ctx.Repo.RepoLink
543+
}
544+
540545
unit, err := ctx.Repo.Repository.GetUnit(ctx, unit_model.TypeExternalTracker)
541546
if err == nil {
542547
ctx.Data["RepoExternalIssuesLink"] = unit.ExternalTrackerConfig().ExternalTrackerURL

routers/web/repo/view.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -711,9 +711,6 @@ func Home(ctx *context.Context) {
711711
feed.ShowRepoFeed(ctx, ctx.Repo.Repository, showFeedType)
712712
return
713713
}
714-
715-
ctx.Data["EnableFeed"] = true
716-
ctx.Data["FeedURL"] = ctx.Repo.Repository.Link()
717714
}
718715

719716
checkHomeCodeViewable(ctx)

routers/web/web.go

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"net/http"
99
"os"
1010
"path"
11+
"strings"
1112

1213
"code.gitea.io/gitea/models/perm"
1314
"code.gitea.io/gitea/models/unit"
@@ -673,16 +674,47 @@ func RegisterRoutes(m *web.Route) {
673674
})
674675
http.ServeFile(ctx.Resp, ctx.Req, path.Join(setting.StaticRootPath, "public/img/favicon.png"))
675676
})
676-
m.Group("/{username}", func() {
677-
m.Get(".png", user.AvatarByUserName)
678-
m.Get(".keys", user.ShowSSHKeys)
679-
m.Get(".gpg", user.ShowGPGKeys)
680-
m.Get(".rss", feedEnabled, feed.ShowUserFeedRSS)
681-
m.Get(".atom", feedEnabled, feed.ShowUserFeedAtom)
682-
m.Get("", user.Profile)
683-
}, func(ctx *context.Context) {
684-
ctx.Data["EnableFeed"] = setting.EnableFeed
685-
}, context_service.UserAssignmentWeb())
677+
m.Get("/{username}", func(ctx *context.Context) {
678+
// WORKAROUND to support usernames with "." in it
679+
// https://github.com/go-chi/chi/issues/781
680+
username := ctx.Params("username")
681+
reloadParam := func(suffix string) (success bool) {
682+
ctx.SetParams("username", strings.TrimSuffix(username, suffix))
683+
context_service.UserAssignmentWeb()(ctx)
684+
return !ctx.Written()
685+
}
686+
switch {
687+
case strings.HasSuffix(username, ".png"):
688+
if reloadParam(".png") {
689+
user.AvatarByUserName(ctx)
690+
}
691+
case strings.HasSuffix(username, ".keys"):
692+
if reloadParam(".keys") {
693+
user.ShowSSHKeys(ctx)
694+
}
695+
case strings.HasSuffix(username, ".gpg"):
696+
if reloadParam(".gpg") {
697+
user.ShowGPGKeys(ctx)
698+
}
699+
case strings.HasSuffix(username, ".rss"):
700+
feedEnabled(ctx)
701+
if !ctx.Written() && reloadParam(".rss") {
702+
context_service.UserAssignmentWeb()(ctx)
703+
feed.ShowUserFeedRSS(ctx)
704+
}
705+
case strings.HasSuffix(username, ".atom"):
706+
feedEnabled(ctx)
707+
if !ctx.Written() && reloadParam(".atom") {
708+
feed.ShowUserFeedAtom(ctx)
709+
}
710+
default:
711+
context_service.UserAssignmentWeb()(ctx)
712+
if !ctx.Written() {
713+
ctx.Data["EnableFeed"] = setting.EnableFeed
714+
user.Profile(ctx)
715+
}
716+
}
717+
})
686718
m.Get("/attachments/{uuid}", repo.GetAttachment)
687719
}, ignSignIn)
688720

tests/integration/api_nodeinfo_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func TestNodeinfo(t *testing.T) {
3333
DecodeJSON(t, resp, &nodeinfo)
3434
assert.True(t, nodeinfo.OpenRegistrations)
3535
assert.Equal(t, "gitea", nodeinfo.Software.Name)
36-
assert.Equal(t, 24, nodeinfo.Usage.Users.Total)
36+
assert.Equal(t, 25, nodeinfo.Usage.Users.Total)
3737
assert.Equal(t, 18, nodeinfo.Usage.LocalPosts)
3838
assert.Equal(t, 2, nodeinfo.Usage.LocalComments)
3939
})

tests/integration/setting_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func TestSettingShowUserEmailExplore(t *testing.T) {
2525
htmlDoc := NewHTMLParser(t, resp.Body)
2626
assert.Contains(t,
2727
htmlDoc.doc.Find(".ui.user.list").Text(),
28-
"user4@example.com",
28+
"user34@example.com",
2929
)
3030

3131
setting.UI.ShowUserEmail = false
@@ -35,7 +35,7 @@ func TestSettingShowUserEmailExplore(t *testing.T) {
3535
htmlDoc = NewHTMLParser(t, resp.Body)
3636
assert.NotContains(t,
3737
htmlDoc.doc.Find(".ui.user.list").Text(),
38-
"user4@example.com",
38+
"user34@example.com",
3939
)
4040

4141
setting.UI.ShowUserEmail = showUserEmail

tests/integration/user_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,19 @@ func testExportUserGPGKeys(t *testing.T, user, expected string) {
241241
assert.Equal(t, expected, resp.Body.String())
242242
}
243243

244+
func TestGetUserRss(t *testing.T) {
245+
user34 := "the_34-user.with.all.allowedChars"
246+
req := NewRequestf(t, "GET", "/%s.rss", user34)
247+
resp := MakeRequest(t, req, http.StatusOK)
248+
if assert.EqualValues(t, "application/rss+xml;charset=utf-8", resp.Header().Get("Content-Type")) {
249+
rssDoc := NewHTMLParser(t, resp.Body).Find("channel")
250+
title, _ := rssDoc.ChildrenFiltered("title").Html()
251+
assert.EqualValues(t, "Feed of "the_1-user.with.all.allowedChars"", title)
252+
description, _ := rssDoc.ChildrenFiltered("description").Html()
253+
assert.EqualValues(t, "<p>some <a href="https://commonmark.org/" rel="nofollow">commonmark</a>!</p>\n", description)
254+
}
255+
}
256+
244257
func TestListStopWatches(t *testing.T) {
245258
defer tests.PrepareTestEnv(t)()
246259

0 commit comments

Comments
 (0)