From 2900dc90a792204a02f4a249399f221d3f9b9c52 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Fri, 4 Nov 2022 17:04:08 +0800 Subject: Improve valid user name check (#20136) Close https://github.com/go-gitea/gitea/issues/21640 Before: Gitea can create users like ".xxx" or "x..y", which is not ideal, it's already a consensus that dot filenames have special meanings, and `a..b` is a confusing name when doing cross repo compare. After: stricter Co-authored-by: Jason Song Co-authored-by: Lunny Xiao Co-authored-by: delvh --- modules/web/middleware/binding.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'modules/web') diff --git a/modules/web/middleware/binding.go b/modules/web/middleware/binding.go index 636e655b9e..cced9717be 100644 --- a/modules/web/middleware/binding.go +++ b/modules/web/middleware/binding.go @@ -135,6 +135,8 @@ func Validate(errs binding.Errors, data map[string]interface{}, f Form, l transl data["ErrorMsg"] = trName + l.Tr("form.glob_pattern_error", errs[0].Message) case validation.ErrRegexPattern: data["ErrorMsg"] = trName + l.Tr("form.regex_pattern_error", errs[0].Message) + case validation.ErrUsername: + data["ErrorMsg"] = trName + l.Tr("form.username_error") default: msg := errs[0].Classification if msg != "" && errs[0].Message != "" { -- cgit v1.2.3