mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-14 04:09:29 +02:00
[GITEA] Fix NPE in UsernameSubRoute
- When the user is not found in `reloadparam`, early return when the user is not found to avoid calling `IsUserVisibleToViewer` which in turn avoids causing a NPE. - This fixes the case that a 500 error and 404 error is shown on the same page. - Add integration test for non-existant user RSS. - Regression byc6366089df
(cherry picked from commitf0e0696278
) (cherry picked from commit75d8066908
) (cherry picked from commit4d0a1e0637
) (cherry picked from commit5f40a485da
) (cherry picked from commitc4cb7812e3
) (cherry picked from commitd31ce2f03d
) (cherry picked from commitcfebef4f82
)
This commit is contained in:
parent
447aa3e499
commit
33b1dec846
2 changed files with 23 additions and 11 deletions
|
@ -715,12 +715,15 @@ func UsernameSubRoute(ctx *context.Context) {
|
|||
reloadParam := func(suffix string) (success bool) {
|
||||
ctx.SetParams("username", strings.TrimSuffix(username, suffix))
|
||||
context_service.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"):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue