diff --git a/backend/utils/validation/notification.go b/backend/utils/validation/notification.go index 6eb77e20..6fd9f752 100644 --- a/backend/utils/validation/notification.go +++ b/backend/utils/validation/notification.go @@ -7,11 +7,9 @@ import ( var ErrNotificationRecipient = errors.New("notification address does not accept mail") -// notification 为主发信账号;notification+system 为历史保留兼容账号。 -// 两者均为系统保留地址,禁止普通用户占用,且拒收任何外部来信。 +// notification 为系统专属发信账号,禁止普通用户占用,且拒收任何外部来信。 const ( - NotificationLocalPart = "notification" - LegacyNotificationLocalPart = "notification+system" + NotificationLocalPart = "notification" ) func NotificationAddress(domain string) string { @@ -21,19 +19,12 @@ func NotificationAddress(domain string) string { return NotificationLocalPart + "@" + domain } -func LegacyNotificationAddress(domain string) string { - if domain == "" { - return "" - } - return LegacyNotificationLocalPart + "@" + domain -} - func IsNotificationAddress(address string, domains []string) bool { parts := strings.Split(strings.ToLower(strings.TrimSpace(address)), "@") if len(parts) != 2 { return false } - if parts[0] != NotificationLocalPart && parts[0] != LegacyNotificationLocalPart { + if parts[0] != NotificationLocalPart { return false } for _, domain := range domains { @@ -52,5 +43,5 @@ func IsAuthorizedNotificationSender(address, domain string) bool { if len(parts) != 2 || !strings.EqualFold(parts[1], domain) { return false } - return parts[0] == NotificationLocalPart || parts[0] == LegacyNotificationLocalPart + return parts[0] == NotificationLocalPart } diff --git a/backend/utils/validation/notification_test.go b/backend/utils/validation/notification_test.go index 253a088f..884d38e6 100644 --- a/backend/utils/validation/notification_test.go +++ b/backend/utils/validation/notification_test.go @@ -1,4 +1,4 @@ -package validation +package validation import "testing" @@ -9,19 +9,13 @@ func TestNotificationAddressAndSenderValidation(t *testing.T) { t.Fatalf("NotificationAddress want notification@example.com, got %s", primarySender) } - legacySender := LegacyNotificationAddress(domain) - if legacySender != "notification+system@example.com" { - t.Fatalf("LegacyNotificationAddress want notification+system@example.com, got %s", legacySender) - } - domains := []string{"example.com", "other.com"} - // 验证 IsNotificationAddress:主地址和历史地址均应被识别为通知地址 if !IsNotificationAddress("notification@example.com", domains) { t.Fatalf("notification@example.com should be recognized as notification address") } - if !IsNotificationAddress("notification+system@example.com", domains) { - t.Fatalf("notification+system@example.com should be recognized as notification address") + if IsNotificationAddress("notification+system@example.com", domains) { + t.Fatalf("notification+system@example.com should NOT be notification address") } if !IsNotificationAddress("NOTIFICATION@OTHER.COM", domains) { t.Fatalf("case insensitive notification address check failed") @@ -30,12 +24,11 @@ func TestNotificationAddressAndSenderValidation(t *testing.T) { t.Fatalf("user@example.com should NOT be notification address") } - // 验证 IsAuthorizedNotificationSender if !IsAuthorizedNotificationSender("notification@example.com", domain) { t.Fatalf("notification@example.com should be authorized sender") } - if !IsAuthorizedNotificationSender("notification+system@example.com", domain) { - t.Fatalf("notification+system@example.com should be authorized sender") + if IsAuthorizedNotificationSender("notification+system@example.com", domain) { + t.Fatalf("notification+system@example.com should NOT be authorized notification sender") } if IsAuthorizedNotificationSender("attacker@example.com", domain) { t.Fatalf("attacker@example.com should NOT be authorized notification sender") diff --git a/frontend/src/views/components/HomeAside/HomeAside.vue b/frontend/src/views/components/HomeAside/HomeAside.vue index a352cea0..e1451e3d 100644 --- a/frontend/src/views/components/HomeAside/HomeAside.vue +++ b/frontend/src/views/components/HomeAside/HomeAside.vue @@ -57,7 +57,7 @@ {{ lang.settings }} - V2.13.0 + V2.13.1