mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 13:04:38 +03:00
normalize localparts with unicode nfc when parsing
both when parsing our configs, and for incoming on smtp or in messages. so we properly compare things like é and e+accent as equal, and accept the different encodings of that same address.
This commit is contained in:
@ -30,7 +30,8 @@ type Domain struct {
|
||||
// letters/digits/hyphens) labels. Always in lower case. No trailing dot.
|
||||
ASCII string
|
||||
|
||||
// Name as U-labels. Empty if this is an ASCII-only domain. No trailing dot.
|
||||
// Name as U-labels, in Unicode NFC. Empty if this is an ASCII-only domain. No
|
||||
// trailing dot.
|
||||
Unicode string
|
||||
}
|
||||
|
||||
@ -87,7 +88,8 @@ func (d Domain) IsZero() bool {
|
||||
// labels (unicode).
|
||||
// Names are IDN-canonicalized and lower-cased.
|
||||
// Characters in unicode can be replaced by equivalents. E.g. "Ⓡ" to "r". This
|
||||
// means you should only compare parsed domain names, never strings directly.
|
||||
// means you should only compare parsed domain names, never unparsed strings
|
||||
// directly.
|
||||
func ParseDomain(s string) (Domain, error) {
|
||||
if strings.HasSuffix(s, ".") {
|
||||
return Domain{}, errTrailingDot
|
||||
|
Reference in New Issue
Block a user