4 ms·
This is why people should write proper code to parse and validate email addresses and not use regex
by roryisok 8y ago
This is why people should write proper code to parse and validate email addresses and not use regex
- 1996 8y agoregex are proper code when written competently
- bzbarsky 8y agoAssuming "competently" means "not using them when the grammar is not regular".
- mcny 8y agoI don’t even try. I put my hands up and accept [anything] @ [anything]
- Drdrdrq 8y agoWell, you can still check MX record for the second "anything", that should be pretty safe, right?
- ryanbrunner 8y agoI don't think that's sufficient on its own. If there's a CNAME on the domain, you'd have to follow the chain of CNAMEs to find an MX record (granted, that's not very common, but I think it's valid usage)
- JdeBP 8y agoResolving proxy DNS servers do that for you. A successful transaction against a resolving proxy DNS server yields a complete answer with all of the alias chain and the final resource record set (or "no such name" indicator). * http://jdebp.info./FGA/dns-query-resolution.html http://jdebp.info./FGA/dns-query-resolution.html
- wongarsu 8y agoAfter you removed the comments from the second anything, and checked that it isn't a raw IPv4 or IPv6 address. jsmith@[IPv6:2001:db8::1] is a valid email address, as is jsmith@(comment)example.com. Though you could argue that there are good reasons to disallow ip-based email addresses.
- Drdrdrq 8y agoThanks, didn't know that! E-mail is really full of surprises. :)