Signed-off-by: tjh x@tjh.dev
+21
-6
appview/email/email.go
+21
-6
appview/email/email.go
···
49
49
parts := strings.Split(addr.Address, "@")
50
50
domain := parts[1]
51
51
52
-
// Ignore err because mx may contain valid records if err != nil anyway.
53
-
mx, _ := net.LookupMX(domain)
52
+
canonical := coalesceToCanonicalName(domain)
53
+
mx, err := net.LookupMX(canonical)
54
54
55
+
// Don't check err here; mx will only contain valid mx records, and we should
56
+
// only fallback to an implicit mx if there are no mx records defined (whether
57
+
// they are valid or not).
55
58
if len(mx) != 0 {
56
59
return true
57
-
} else {
58
-
// Ignore err because addr will be nil if any errors occur anyway.
59
-
addr, _ := net.LookupIP(domain)
60
-
if len(addr) != 0 {
60
+
}
61
+
62
+
if err != nil {
63
+
// If the domain resolves to an address, assume it's an implicit mx.
64
+
address, _ := net.LookupIP(canonical)
65
+
if len(address) != 0 {
61
66
return true
62
67
}
63
68
}
64
69
65
70
return false
66
71
}
72
+
73
+
func coalesceToCanonicalName(domain string) string {
74
+
canonical, err := net.LookupCNAME(domain)
75
+
if err != nil {
76
+
// net.LookupCNAME() returns an error if there is no cname record *and* no
77
+
// a/aaaa records, but there may still be mx records.
78
+
return domain
79
+
}
80
+
return canonical
81
+
}
+2
-2
flake.lock
+2
-2
flake.lock
···
120
120
"lastModified": 1731402384,
121
121
"narHash": "sha256-OwUmrPfEehLDz0fl2ChYLK8FQM2p0G1+EMrGsYEq+6g=",
122
122
"type": "tarball",
123
-
"url": "https://github.com/IBM/plex/releases/download/@ibm/plex-mono@1.1.0/ibm-plex-mono.zip"
123
+
"url": "https://github.com/IBM/plex/releases/download/@ibm%2Fplex-mono@1.1.0/ibm-plex-mono.zip"
124
124
},
125
125
"original": {
126
126
"type": "tarball",
127
-
"url": "https://github.com/IBM/plex/releases/download/@ibm/plex-mono@1.1.0/ibm-plex-mono.zip"
127
+
"url": "https://github.com/IBM/plex/releases/download/@ibm%2Fplex-mono@1.1.0/ibm-plex-mono.zip"
128
128
}
129
129
},
130
130
"indigo": {
History
3 rounds
4 comments
1 commit
expand
collapse
appview: expand domain of acceptable email addresses
Use address resolution steps from RFC5321 section 5.1 when validating
email addresses.
ref: https://datatracker.ietf.org/doc/html/rfc5321#section-5.1
Signed-off-by: tjh <x@tjh.dev>
I can confirm I have no fixed my dev setup and have manually tested this.