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
+23 -8
Interdiff #0 โ†’ #1
+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
··· 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
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
tjh.dev submitted #1
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.