diff --git a/services/context/captcha.go b/services/context/captcha.go index da837acb00..58c9205d54 100644 --- a/services/context/captcha.go +++ b/services/context/captcha.go @@ -5,6 +5,7 @@ package context import ( "fmt" + "math/rand" "sync" "code.gitea.io/gitea/modules/base" @@ -55,7 +56,9 @@ func GetImageCaptcha() string { imageCaptchaOnce.Do(func() { captcha.SetCustomStore(&imageCaptchaStore{c: cache.GetCache()}) }) - return captcha.New() + + length := 4 + rand.Intn(2) // 4 or 5 chars + return captcha.NewLen(length) } // SetCaptchaData sets common captcha data