Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix: accept display name in email notification From Address (#3776)
Ligo034e7e7efd4e
diff --git a/frontend/messages/en.json b/frontend/messages/en.jsonindex 44d5f176e..2e9503632 100644--- a/frontend/messages/en.json+++ b/frontend/messages/en.json@@ -2375,7 +2375,7 @@"notifications_email_password_help": "SMTP authentication password","notifications_email_from_address_label": "From Address","notifications_email_from_address_placeholder": "[email protected]",- "notifications_email_from_address_help": "Email address to send notifications from",+ "notifications_email_from_address_help": "Email address to send notifications from. You can optionally include a display name, e.g. Arcane <[email protected]>","notifications_email_to_addresses_label": "To Addresses","notifications_email_to_addresses_placeholder": "[email protected], [email protected]","notifications_email_to_addresses_help": "Comma-separated list of email addresses to send notifications to",diff --git a/frontend/src/routes/(app)/settings/notifications/providers/BuiltInProviderForm.svelte b/frontend/src/routes/(app)/settings/notifications/providers/BuiltInProviderForm.svelteindex 9680b550b..6aa312aee 100644--- a/frontend/src/routes/(app)/settings/notifications/providers/BuiltInProviderForm.svelte+++ b/frontend/src/routes/(app)/settings/notifications/providers/BuiltInProviderForm.svelte@@ -22,6 +22,22 @@const GENERIC_PAYLOAD_TEMPLATE_VARS ='{{.title}}, {{.message}}, {{.environment}}, {{.environmentId}}, {{.event}}, {{.timestamp}}';+ // Accepts RFC 5322 "Display Name <[email protected]>" as well as a bare address,+ // matching what backend/pkg/utils/notifications parses with net/mail.ParseAddress.+ // The display name must be either a quoted string (which may contain "<"/">") or an+ // unquoted phrase without "@", angle brackets, quotes, or commas; anything else is left+ // as-is so the surrounding email check rejects the whole malformed string.+ function extractEmailAddress(value: string): string {+ const match = value.match(/^\s*(.*?)\s*<([^<>]+)>\s*$/);+ if (!match) return value;+ const namePart = (match[1] ?? '').trim();+ const address = (match[2] ?? '').trim();+ if (namePart === '') return address;+ const isQuotedName = /^"(?:[^"\\]|\\.)*"$/.test(namePart);+ const isUnquotedName = /^[^"<>,@]+$/.test(namePart);+ return isQuotedName || isUnquotedName ? address : value;+ }+interface Props {provider: NotificationProviderKey;values: AnyBuiltInValues;@@ -104,7 +120,7 @@if (!d.fromAddress.trim()) {ctx.addIssue({ code: 'custom', message: m.common_required(), path: ['fromAddress'] });} else {- const v = z.string().email().safeParse(d.fromAddress.trim());+ const v = z.string().email().safeParse(extractEmailAddress(d.fromAddress.trim()));if (!v.success) {ctx.addIssue({ code: 'custom', message: m.common_invalid_email(), path: ['fromAddress'] });}@@ -423,8 +439,7 @@id: 'from-address',label: m.notifications_email_from_address_label(),placeholder: m.notifications_email_from_address_placeholder(),- helpText: m.notifications_email_from_address_help(),- inputType: 'email'+ helpText: m.notifications_email_from_address_help()},{kind: 'textarea',