Monorepo for Tangled tangled.org

appview: expand domain of acceptable email addresses #1217

merged opened by tjh.dev targeting master from tjh.dev/core: push-oxmnukovusmv
Labels

None yet.

assignee

None yet.

Participants 2
AT URI
at://did:plc:65gha4t3avpfpzmvpbwovss7/sh.tangled.repo.pull/3mhqk2ydqc622
+27 -4
Diff #2
+27 -4
appview/email/email.go
··· 49 49 parts := strings.Split(addr.Address, "@") 50 50 domain := parts[1] 51 51 52 - mx, err := net.LookupMX(domain) 53 - if err != nil || len(mx) == 0 { 54 - return false 52 + canonical := coalesceToCanonicalName(domain) 53 + mx, err := net.LookupMX(canonical) 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). 58 + if len(mx) != 0 { 59 + return true 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 { 66 + return true 67 + } 55 68 } 56 69 57 - return true 70 + return false 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 58 81 }

History

3 rounds 4 comments
sign up or login to add to the discussion
1 commit
expand
appview: expand domain of acceptable email addresses
expand 3 comments

I can confirm I have no fixed my dev setup and have manually tested this.

s/no/now

Nice, LGTM!

pull request successfully merged
1 commit
expand
appview: expand domain of acceptable email addresses
expand 0 comments
tjh.dev submitted #0
1 commit
expand
appview: expand domain of acceptable email addresses
expand 1 comment

I haven't tested this because my dev setup is broken.