25
jeeper
20d

Yes you can have hyphens in email addresses, you incompetent nincompoops!!! Just use the standard regex for email validation and stop trying to make your own rules!!!!

Comments
  • 10
    If I had a nickel for every time some non-technical fuckwit insisted we use a non-standards oriented metric for email validation, I wouldn't need VC money.
  • 0
    So anybody use the mx record validation? I feel it does lot of false positive
  • 5
    @SortOfTested not even joking, the email verification for one of the projects I saw at work?

    .contains("@")
  • 0
    @devapsarl

    MX Record is not always needed.
  • 1
    Afaik there's no standard regex reliably validating an email. There are good-enough attempts tho... Even apache's validator has flaws
  • 2
    @AlgoRythm
    To be honest: If you do verification by email, just cheking for "@" actually is enough.
    The email standard is one of the first internet standards and therefore contains some traps and outdated crap nobody uses anymore (source paths, quoted dot-separated atoms, comments in the local part - yep, i WTFed too).

    I never saw a fully standard-complient validation routine.
    And i would actually advice against trying to be full standards-compliant anyway.
    Don't allow quoted parts, comments, or source routes. They don't exist in the wild and only add more complexity for literally no gain.
    But definitely allow top-level domains and IP-addresses. There are people having such addresses.
  • 3
    @Oktokolo Yeah, but just "@" is not a valid email address.... I would hope at the very least match a regex like

    /.+@.+/
  • 2
    @netikras if theres anything that is better than the 99% that emailregex.com gets then it’s gonna come out of an academic research environment, not some cheap web app. 99% of devs need to just use that
  • 3
    @jeeper
    Fails for international local parts and domains.
    https://en.wikipedia.org/wiki/...
    Fails also for toplevel domains.

    I think, just checking for "@" literally is better than that page-long regexp. No, i am not an academic.
  • 1
    @Oktokolo i usually use /.+@.+\..{2,}/ when live-validating because the feedback feels more natural than just using @. But wtf there are IP E-Mails? Who the fuck uses that lmao
  • 0
    There's at least one major UK bank that doesn't accept emails blah@blah.wales or blah@blah.cymru
  • 0
    @nibor
    Grats, you found someone who didn't just copypasted some ominous regexp from emailregex.com he didn't even dared trying to understand what it does... No, that one even got the extra mile and added a TLD whitelist to his code stew.
  • 2
    @eval
    I don't know your experience with folks working for TLD providers. But they can have email addresses in the form of "joedoe@com".
    Most don't, but that might change with the proliferation of commercial TLDs.

    And yes: You can use an IP address as a host name - even for email.
    Never saw one myself, but i see no reason to block them.
  • 1
    What is the worst that can happen if you accept an illegal email anyway? Assuming that you otherwise follow basic security procedures.
  • 0
    @Lor-inc
    An email doesn't reach any person or reaches the wrong person.
    So it is the same as it is for postal addresses or telefax numbers.
  • 1
    @Oktokolo In that case why bother, when I can give "yomama@fuckoff.com" and bypass any regex?
    The only real test is email verification, and it's so much simpler as well. If you really want to, you can check if it vaguely resembles an email. I.e. contains a @.
  • 2
    Btw my hobby is feeding addresses like 0@gmail.com to WiFi walls in the hopes that they get flagged as spam.
  • 0
    @Lor-inc
    The whole email syntax check fetish actually has a solid and reasonable root:
    Making users aware about the fact, that they just pasted something completely unrelated into the email field.
    Just checking for the "@" catches indeed most of that.
    A lot of sites let users fill two fileds with the same address to get better error detection, but users normaly just copy the address from field 1 and paste it into field two - so it always matches regardless of typos...

    Do WiFi hotspots now actually send any emails?
    I always thought, they are just hording emails so the can mark the "you have to get something identifying the user in case he uses your WiFi to rape a child" checkbox.
  • 0
    @Oktokolo Thameslink does.
  • 0
    @Linux thought was needed to check if email really exists
  • 0
    @devapsarl

    It is quite common for people to just have everything behind the same IP, and therefore only the A Record is needed, technically
Add Comment