fix: various bugs (#39661)

1. fix #39660: relax email validation
2. fix #39658: use "int64" instead of time.Duration (for JSON v2)
This commit is contained in:
wxiaoguang authored and GitHub committed 2026-10-08 00:33:55 +08:00
1 parent 4cba1e18ed
commit 5a529ffd58
4 files changed
+36 -19

No files matched your search

+20 -8
View File
@@ -151,16 +151,28 @@ func TestListEmails(t *testing.T) {
func TestEmailAddressValidate(t *testing.T) {
cases := map[string]bool{
"": false,
"root@localhost": true,
"user@[192.168.1.2]": true,
"@a": false,
"abc@gmail.com": true,
"abc@gmail.com\n": false,
"": false,
"@a": false,
// "_" shouldn't appear in domain but can appear in hostname, since we can't stop site admins from doing so, just accept it
"root@local_host": true,
"root@localhost": true,
"root@LOCALHOST": true,
"user@[192.168.1.2]": true,
"user@[IPv6:FFff::1]": true,
"abc@gmail.com": true,
"abc@gmail.com.": false,
"abc@gmail.com-": false,
"abc@gmail.com\n": false,
"abc@gmail..com": false,
"abc@gmail com": false,
"abc@gmail*com": false,
"Foo <foo@bar.com>": false,
"abc@gmail.com (x)": false,
"jürgen@example.com": false,
"a@foo_bar.com": false,
"jürgen@example.com": false, // utf8 address is not supported yet
}
for tc, isValid := range cases {
t.Run(tc, func(t *testing.T) {