I'm having an interesting case, where email addresses with newlines are seen as valid, but carriage returns and/or carriage returns, with a newline aren't seen as valid:

[snip]

#!perl
use strict;

use Test::More tests => 4;

BEGIN {
  use_ok('Email::Valid');
}
my $email;

$email = '[EMAIL PROTECTED]' . "\r";
ok(Email::Valid->address(-address => $email) eq undef, 'addresses with "\r" at the end return undefined');
diag(Email::Valid->address(-address => $email));

$email = '[EMAIL PROTECTED]' . "\r\n";
ok(Email::Valid->address(-address => $email) eq undef, 'addresses with "\r\n" at the end return undefined');
diag(Email::Valid->address(-address => $email));

$email = '[EMAIL PROTECTED]' . "\n";
ok(Email::Valid->address(-address => $email) eq undef, 'addresses with "\n" at the end return undefined');
diag ("'" . Email::Valid->address(-address => $email) ."'");

[/snip]

Does that sound like the correct behavior? Here's the output I get:

[snip]
1..4
ok 1 - use Email::Valid;
ok 2 - addresses with "\r" at the end return undefined
# undef
ok 3 - addresses with "\r\n" at the end return undefined
# undef
not ok 4 - addresses with "\n" at the end return undefined
#   Failed test 'addresses with "\n" at the end return undefined'
#   at /Users/justin/Desktop/test.pl line 20.
# '[EMAIL PROTECTED]'
# Looks like you failed 1 test of 4.
[/snip]

That regex in Email::Valid is scary, although this line seems a little suspicious:

        $RFC822PAT =~ s/\n//g;

(last line, before the, 1; in the module).

Is this a bug, known issue, or some quirk of that regex? fudge() is set to, "false" by default - so I'm assuming that no attempts at making the address is corrected are done. The URL to the Book's code examples is 404'ing and it's time for me to go to sleep :)

Justin









Reply via email to