Development hosts, review V-1 to V-3: a malformed list stops the start, a trailing dot and Unicode patterns match, every send reads the store
- V-1: assertDevelopmentHosts - iapl({ developmentHosts }), mail.relay.developmentHosts and
mailAdapter({ relay }) refuse anything but an array of non-empty host patterns, and a pattern of `*` alone
(it would make the public site a development address). Nothing is ignored silently any more.
- V-2: one trailing dot of the host is stripped before matching; patterns are punycoded, so one written in
Unicode matches; a `*` inside a non-ASCII label is refused.
- V-3: the 30-second memory of other hosts is gone. A dump restored into a running development site stops
its very next e-mail.
- docs, AGENT.md, changelog draft, skills
Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
99c73ed0ff
commit
6c4e244094
@@ -2,7 +2,7 @@ import type { BasePayload, SendEmailOptions } from 'payload'
|
||||
|
||||
import type { MailKind } from './kinds.js'
|
||||
|
||||
import { DEFAULT_DEVELOPMENT_HOSTS } from '../../shared/developmentHosts.js'
|
||||
import { assertDevelopmentHosts, DEFAULT_DEVELOPMENT_HOSTS } from '../../shared/developmentHosts.js'
|
||||
import { RELAY_BASE_URL } from './constants.js'
|
||||
|
||||
/**
|
||||
@@ -102,7 +102,8 @@ export function pluginMailOptions(payload: Pick<BasePayload, 'config'>): PluginM
|
||||
*/
|
||||
export function pluginDevelopmentHosts(payload: Pick<BasePayload, 'config'>): string[] {
|
||||
const own = (payload.config?.custom as { iapl?: { developmentHosts?: unknown } } | undefined)?.iapl?.developmentHosts
|
||||
return Array.isArray(own) ? own.filter((p): p is string => typeof p === 'string') : [...DEFAULT_DEVELOPMENT_HOSTS]
|
||||
// (written by iapl(), which refuses a malformed list; a value put here by hand is checked the same way)
|
||||
return own === undefined ? [...DEFAULT_DEVELOPMENT_HOSTS] : assertDevelopmentHosts(own, 'config.custom.iapl.developmentHosts')
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,6 +114,7 @@ export function resolveRelayOptions(payload: Pick<BasePayload, 'config'>, own?:
|
||||
const fromPlugin = pluginMailOptions(payload).relay
|
||||
if (own === false || (own === undefined && fromPlugin === false)) {return null}
|
||||
const merged: RelayOptions = { ...(fromPlugin || {}), ...(own || {}) }
|
||||
if (merged.developmentHosts !== undefined) {assertDevelopmentHosts(merged.developmentHosts, 'mail.relay.developmentHosts')}
|
||||
const url = (merged.url ?? RELAY_BASE_URL).replace(/\/+$/, '')
|
||||
return { ...merged, developmentHosts: merged.developmentHosts ?? pluginDevelopmentHosts(payload), ownUrl: url !== RELAY_BASE_URL, url }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user