mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 17:44:35 +03:00
Allow multiple localpart catch all separators, e.g. both "+" and "-", for addresses you+anything@example.com and you-anything@example.com
The original config option stays, and we still use it for the common case where we have a single separator. The "+" is configured by default. It is optional, just like the new option "LocalpartCatchallSeparators" (plural). When parsing the config file, we combine LocalpartCatchallSeparator and LocalpartCatchallSeparators into a single list LocalpartCatchallSeparatorsEffective, which we use throughout the code. For issue #301 by janc13
This commit is contained in:
@ -86,10 +86,10 @@ func LookupAddress(localpart smtp.Localpart, domain dns.Domain, allowPostmaster,
|
||||
}
|
||||
|
||||
// CanonicalLocalpart returns the canonical localpart, removing optional catchall
|
||||
// separator, and optionally lower-casing the string.
|
||||
// separators, and optionally lower-casing the string.
|
||||
func CanonicalLocalpart(localpart smtp.Localpart, d config.Domain) smtp.Localpart {
|
||||
if d.LocalpartCatchallSeparator != "" {
|
||||
t := strings.SplitN(string(localpart), d.LocalpartCatchallSeparator, 2)
|
||||
for _, sep := range d.LocalpartCatchallSeparatorsEffective {
|
||||
t := strings.SplitN(string(localpart), sep, 2)
|
||||
localpart = smtp.Localpart(t[0])
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user