feat: relax email requirements (#7829)

The current email restrictions were put in place because of a security issue with sendmail (https://github.com/go-gitea/gitea/pull/17688). Remove this restriction and instead ensure that this security issue cannot happen with sendmail.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7829
Reviewed-by: Ellen Εμιλία Άννα Zscheile <fogti@noreply.codeberg.org>
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: famfo <famfo@famfo.xyz>
Co-committed-by: famfo <famfo@famfo.xyz>
This commit is contained in:
famfo 2025-05-22 12:20:25 +02:00 committed by Gusted
parent de1adf224d
commit dda37e86bd
11 changed files with 45 additions and 46 deletions

View file

@ -35,7 +35,7 @@ func TestEmailAddressValidate(t *testing.T) {
`first|last@iana.org`: nil,
`first}last@iana.org`: nil,
`first~last@iana.org`: nil,
`first;last@iana.org`: ErrEmailCharIsNotSupported{`first;last@iana.org`},
`first;last@iana.org`: ErrEmailInvalid{`first;last@iana.org`},
".233@qq.com": ErrEmailInvalid{".233@qq.com"},
"!233@qq.com": nil,
"#233@qq.com": nil,
@ -45,7 +45,7 @@ func TestEmailAddressValidate(t *testing.T) {
"'233@qq.com": nil,
"*233@qq.com": nil,
"+233@qq.com": nil,
"-233@qq.com": ErrEmailInvalid{"-233@qq.com"},
"-233@qq.com": nil,
"/233@qq.com": nil,
"=233@qq.com": nil,
"?233@qq.com": nil,
@ -56,9 +56,10 @@ func TestEmailAddressValidate(t *testing.T) {
"|233@qq.com": nil,
"}233@qq.com": nil,
"~233@qq.com": nil,
";233@qq.com": ErrEmailCharIsNotSupported{";233@qq.com"},
"Foo <foo@bar.com>": ErrEmailCharIsNotSupported{"Foo <foo@bar.com>"},
string([]byte{0xE2, 0x84, 0xAA}): ErrEmailCharIsNotSupported{string([]byte{0xE2, 0x84, 0xAA})},
"\"~@ \"@famfo.xyz": nil,
"Foo <foo@bar.com>": ErrEmailInvalid{"Foo <foo@bar.com>"},
";233@qq.com": ErrEmailInvalid{";233@qq.com"},
string([]byte{0xE2, 0x84, 0xAA}): ErrEmailInvalid{string([]byte{0xE2, 0x84, 0xAA})},
}
for kase, err := range kases {
t.Run(kase, func(t *testing.T) {