Live data from Hacker News

Stop Validating Email Addresses with Regex (2012)

davidcel.is

31–40 of 228 posts

Re: Stop Validating Email Addresses with Regex (2012)

#31
post #15

This is horrible advice. If you don't check input for correctness at all, an attacker could inject all kinds of nastyness into am underlying system, which may expose bugs. For example, control characters, line breaks, shell escape characters, SQL injections, or simply uploading an ISO image into the E-mail field. There is the RFC, and there is what we would nowadays consider a sane E-mail address. Nobody has addresse…

No post body was provided.

Re: Stop Validating Email Addresses with Regex (2012)

#32

Earlier quoted context omitted.

The most underrated crypto thing that people don't discuss enough, is that i don't need an email account to interact with web3 apps, i just sign in with metamask. if I could do it for every single app around that would be great.

What's wrong with a username and password?

To answer this, ask why you use an SSH key to authenticate with all of your servers.

Re: Stop Validating Email Addresses with Regex (2012)

#33
You actually should at least use regex to check some basic things. Like "@" "." or even just disallowed characters.

As someone who sends a LOT of email for customers every week, a big percentage of our problem is incorrectly formatted emails. So we just don't even let them in these days.

People are forgetting that for services that have to send email it costs dearly to bounce.

Bounces decrease the quality of your list and you can get penalized by your email provider. By letting in stupid sh*t, you just are compromising yourself. So some simple regex that gets rid of the most egregious stuff is worth it.

Re: Stop Validating Email Addresses with Regex (2012)

#34
Does anyone on HN have any of these "surprising" email addresses that most people and developers do not expect?

How does it work with common e-mail clients? How do people react when you show/tell them your email?

I have a domain that uses non-ascii characters, and while I can receive emails on that domain, hosted by Fastmail, Fastmail clients refuses to _send_ emails to that domain (I can, if I type the domain as Punycode).

Re: Stop Validating Email Addresses with Regex (2012)

#35
This won't be popular, but:

1. An experienced dev just killed 54k stars on GitHub due to pressing a button in an auto-pilot mode. Do you think a Joe High who wants to give you $100 won't ever type '2' instead of '@'? What about an old lady? Or someone with physical difficulties? Have you personally ever made a typo in an email?

2. That code in the article is not color highlighted (rainbowed for Regex) or formatted properly. If I write something in any language in one line without highlighting — it'd look unreadable as well.

3. A Regex for this specific purpose is write-once-and-forget. You won't need to edit it for 20 years.

4. Regex — for practical tasks — is way easier than it's being painted. Not easy — just not as hard as some suggest.

5. I'm not a Regex fanboy (nobody is).

Re: Stop Validating Email Addresses with Regex (2012)

#36
Ten-year-old article. Everyone still uses regexes, including browsers. World has not ended, I rest my case.

Some negligible fraction of pathological email addresses will get rejected by imperfect regular expressions. I’ve tested multiple email validation regexes against huge databases of actual emails and found they all validate.

Re: Stop Validating Email Addresses with Regex (2012)

#37

Can't upvote this enough. There simply is no need to check the email addr provided by the user. Send the mail, if it bounces, the user has only himself to blame. What if I don't want them to go through the hassle of an activation link? Then I don't bother with an email account in the sign-up process in the first place. If they want a passwd reset method, they can later provide an email in their settings page, if that…

Don’t most emailing services heavily penalize a high bounce rate, including banning of the commercial account if it goes on for too long ?

(which as far as I understand is also to protect the emailing service from getting blocked itself)

Re: Stop Validating Email Addresses with Regex (2012)

#39
post #17

RFCs for email addresses are cool, but on the web we have our own standards! https://html.spec.whatwg.org/multipage/input.html#valid-e-ma... "This requirement is a willful violation of RFC 5322, which defines a syntax for email addresses that is simultaneously too strict (before the "@" character), too vague (after the "@" character), and too lax (allowing comments, whitespace characters, and quoted strings in manner…

I like your final sentence. Very to-the-point.
Post reply on HN