pali / Email-Address-XS

Parse and format RFC 5322 email addresses and groups
https://metacpan.org/pod/Email::Address::XS
1 stars 1 forks source link

Accepts bad.@example.com as valid address #2

Closed madsen closed 6 years ago

madsen commented 6 years ago

Email::Address::XS 1.03 accepts an address with a period right before the @ sign. As I read RFC 5322, the local-part cannot end with a period unless it is a quoted-string.

That is, I expect the following:

Email::Address::XS->parse('good@example.com')->is_valid; # true
Email::Address::XS->parse('bad.@example.com')->is_valid; # false
Email::Address::XS->parse('bad.address.@example.com')->is_valid; # false
Email::Address::XS->parse('"ok."@example.com')->is_valid; # true

but they all return true.

This is a problem when using Email::Address::XS to validate addresses that will be passed to Email::Sender, which still uses Email::Address. Email::Address 1.908 does not accept ".@", so you can get a "no recipients" error from Email::Sender even though Email::Address::XS claims the address is valid.

pali commented 6 years ago

Thanks for report. You are right that such addresses are invalid per RFCs. It is caused by dovecot parser which successfully parse these addresses. And I was told that reason is because some emails really contains such addresses in email headers. I would wait how upstream dovecot want to solve this problem and based on this I decide for proper fix in Email::Address::XS.

pali commented 6 years ago

Now I committed some fixes for validation of email addresses into git master branch. Please test and let me know if there are still some problems.

pali commented 6 years ago

New version 1.04 of Email::Address::XS with these changes were release to CPAN.