Perl-Email-Project / Email-Valid

perl library to validate email addresses
19 stars 19 forks source link

Reports addresses of the form `<email@domain.com>` as invalid #16

Open oschwald opened 9 years ago

oschwald commented 9 years ago

From a brief review of RFC 5322, I think this is valid, even without a display-name. I'd submit a PR, but that regex is a thing of nightmares.

rjbs commented 8 years ago

That should be valid, yes. I am not enthused to poke that regex either. ;)

pali commented 8 years ago

In my opinion such email address is not valid.

There are three different things: 1) Content of To header 2) ABNF grammar for mailbox field in RFCs 3) ABNF grammar for addr-spec filed in RFCs

If you are talking about list of email addresses then it is option 1) If you are talking about one email address phrase then it is option 2) And if you are talking about one bare email address (without phrase and without comments) then it is option 3).

And I understand that this modules check validity of email address as option 3. There is no support for comments or phrase...

mgruner commented 7 years ago

I'm not sure that @pali's analysis is correct, please also see #36. Email::Valid accepts a number of complex formats, including "Firstname Lastname" (Comment) <address@domain.tld>.

In the long run that regex will have to be changed at some point I guess, right now it is an ugly example of write-only code. See http://search.cpan.org/~miyagawa/Email-Valid-Loose-0.05/lib/Email/Valid/Loose.pm for a previous attempt to achieve that. I tried a similar approach on the current regex (which seems to be different) without success so far.

pali commented 7 years ago

Hm... then first, module should document what kind of validation is doing (option 1., 2. or 3.) and after start start it fixing. Because it is really misleading.