From 285f66b782491d05e35aa81a6e1a0fede85069b4 Mon Sep 17 00:00:00 2001 From: oliverpool Date: Thu, 19 Jun 2025 18:31:08 +0200 Subject: [PATCH] fix: prevent 500 message on invalid username (#8236) Bug introduced by #7998 ### Tests - go to your settings page https://v12.next.forgejo.org/user/settings - try to change to an invalid username (like `.well--invalid`) - verify that no 500 error is shown, only a flash message I tried to add a test in `tests/integration/user_test.go`, but failed to catch the error message: ``` resp := session.MakeRequest(t, req, http.StatusOK) txt := resp.Body.String() t.Log(txt) // no template error?? t.FailNow() ``` ### Release notes - [x] I do not want this change to show in the release notes. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8236 Reviewed-by: 0ko <0ko@noreply.codeberg.org> Co-authored-by: oliverpool Co-committed-by: oliverpool --- routers/web/user/setting/profile.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/routers/web/user/setting/profile.go b/routers/web/user/setting/profile.go index 0ddb1b21f5..400ee71f08 100644 --- a/routers/web/user/setting/profile.go +++ b/routers/web/user/setting/profile.go @@ -66,6 +66,9 @@ func ProfilePost(ctx *context.Context) { ctx.Data["DisableGravatar"] = setting.Config().Picture.DisableGravatar.Value(ctx) ctx.Data["CooldownPeriod"] = setting.Service.UsernameCooldownPeriod ctx.Data["CommonPronouns"] = commonPronouns + ctx.Data["MaxAvatarFileSize"] = setting.Avatar.MaxFileSize + ctx.Data["MaxAvatarWidth"] = setting.Avatar.MaxWidth + ctx.Data["MaxAvatarHeight"] = setting.Avatar.MaxHeight if ctx.HasError() { ctx.HTML(http.StatusOK, tplSettingsProfile)