aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/user
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2024-03-13 14:57:30 +0800
committerGitHub <noreply@github.com>2024-03-13 06:57:30 +0000
commit67e9f0d49828f62a942ac6db04153207f88e82ee (patch)
treea2d7871a69039d3a32467d914933c695df87828e /routers/web/user
parent9a93b1816e0bc65101e7ad7ca66786fb38a8e628 (diff)
downloadgitea-67e9f0d49828f62a942ac6db04153207f88e82ee.tar.gz
gitea-67e9f0d49828f62a942ac6db04153207f88e82ee.zip
Fix user router possbile panic (#29751)
regression from #28023
Diffstat (limited to 'routers/web/user')
-rw-r--r--routers/web/user/home.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/routers/web/user/home.go b/routers/web/user/home.go
index caa7115259..e731a2a9b7 100644
--- a/routers/web/user/home.go
+++ b/routers/web/user/home.go
@@ -714,12 +714,16 @@ func UsernameSubRoute(ctx *context.Context) {
reloadParam := func(suffix string) (success bool) {
ctx.SetParams("username", strings.TrimSuffix(username, suffix))
context.UserAssignmentWeb()(ctx)
+ if ctx.Written() {
+ return false
+ }
+
// check view permissions
if !user_model.IsUserVisibleToViewer(ctx, ctx.ContextUser, ctx.Doer) {
ctx.NotFound("user", fmt.Errorf(ctx.ContextUser.Name))
return false
}
- return !ctx.Written()
+ return true
}
switch {
case strings.HasSuffix(username, ".png"):
@@ -740,7 +744,6 @@ func UsernameSubRoute(ctx *context.Context) {
return
}
if reloadParam(".rss") {
- context.UserAssignmentWeb()(ctx)
feed.ShowUserFeedRSS(ctx)
}
case strings.HasSuffix(username, ".atom"):