Subject: | failure on trailing garbage at end of address |
Date: | Thu, 04 Oct 2012 18:50:23 +0100 |
To: | bug-Email-Valid [...] rt.cpan.org |
From: | Iain Paton <ipaton0 [...] gmail.com> |
using Email::Valid 0.190 an address of the form 'something@perl.com ' where there's a trailing character after the .com that's somehow invalid, a space or some corrupt attempt at unicode, Email::Valid will tell me that it's a valid email address.
This can be replicated simply by the following:
my $r=Email::Valid->address('something@invalid.com ');
This seems to be down to reading the passed in address using Mail::Address->parse as follows:
($addr) = Mail::Address->parse( $addr );
Since Mail::Address->parse seems to be intended to extract email addresses from complete lines in email headers it first tokenizes the input, thereby discarding any leading/trailing stuff it doesn't like.
Changing Email::Valid to use
($addr)=Mail::Address->new('',$addr);
means that it returns an error of fqdn. Of course that could have other effects if people rely on that behaviour somehow.
It seems likely that this particular behaviour from Mail::Address->parse is what's behind #75650 as well.
Anyway, don't know if this is easily fixable, but thought it was worth reporting anyway.