Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Email-Valid CPAN distribution.

Report information
The Basics
Id: 75736
Status: resolved
Priority: 0/
Queue: Email-Valid

People
Owner: Nobody in particular
Requestors: carnil [...] debian.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



From: CARNIL [...] cpan.org
Subject: libemail-valid-perl: does not handle "0@valid-email.com" correctly
Hi This bug has been forwarded from http://bugs.debian.org/663663 There is a corner case with valid email addresses which seems to give false-positive: It can be reproduced with: $ perl -MEmail::Valid -e 'print Email::Valid->address("1\@stanford.edu") ? "yes\n" : "no\n"' yes $ perl -MEmail::Valid -e 'print Email::Valid->address("0\@stanford.edu") ? "yes\n" : "no\n"' no Could you have a look at it? Thanks in advance, Salvatore Bonaccorso, Debian Perl Group
On Tue Mar 13 08:44:23 2012, CARNIL wrote: Show quoted text
> Hi > > This bug has been forwarded from http://bugs.debian.org/663663 > > There is a corner case with valid email addresses which seems to give > false-positive: It can be reproduced with: > > $ perl -MEmail::Valid -e 'print Email::Valid-
> >address("1\@stanford.edu") ? "yes\n" : "no\n"'
> yes > $ perl -MEmail::Valid -e 'print Email::Valid-
> >address("0\@stanford.edu") ? "yes\n" : "no\n"'
> no > > Could you have a look at it?
I'll do some testing and code-browsing tonight and/or tomorrow morning. Steve
This patch (which I've also attached) should fix the bug. I'm sorry. I introduced this bug myself. diff -urN Email-Valid-0.187/lib/Email/Valid.pm Email-Valid-0.187.new/lib/Email/Valid.pm --- Email-Valid-0.187/lib/Email/Valid.pm 2012-01-27 11:27:00.000000000 -0500 +++ Email-Valid-0.187.new/lib/Email/Valid.pm 2012-03-13 18:58:30.273470406 -0400 @@ -286,7 +286,7 @@ sub _valid_local_part { my ($self, $localpart) = @_; - return 0 unless $localpart and length $localpart <= 64; + return 0 unless defined $localpart and length $localpart <= 64; return 1; } diff -urN Email-Valid-0.187/t/valid.t Email-Valid-0.187.new/t/valid.t --- Email-Valid-0.187/t/valid.t 2012-01-27 11:27:27.000000000 -0500 +++ Email-Valid-0.187.new/t/valid.t 2012-03-13 19:16:57.119508104 -0400 @@ -1,7 +1,7 @@ #!perl use strict; -use Test::More tests => 31; +use Test::More tests => 33; BEGIN { use_ok('Email::Valid'); @@ -80,6 +80,18 @@ "space between @ and domain is valid", ); +is( + $v->address(-address => '1@example.com', -localpart => 1), + '1@example.com', + "localpart in true context succeeds", +); + +is( + $v->address(-address => '0@example.com', -localpart => 1), + '0@example.com', + "localpart in false context is defined (bug 75736)", +); + ok( $v->address('-dashy@example.net'), 'an email can start with a dash',
Subject: email_valid_0-187-bug75736.patch
diff -urN Email-Valid-0.187/lib/Email/Valid.pm Email-Valid-0.187.new/lib/Email/Valid.pm --- Email-Valid-0.187/lib/Email/Valid.pm 2012-01-27 11:27:00.000000000 -0500 +++ Email-Valid-0.187.new/lib/Email/Valid.pm 2012-03-13 18:58:30.273470406 -0400 @@ -286,7 +286,7 @@ sub _valid_local_part { my ($self, $localpart) = @_; - return 0 unless $localpart and length $localpart <= 64; + return 0 unless defined $localpart and length $localpart <= 64; return 1; } diff -urN Email-Valid-0.187/t/valid.t Email-Valid-0.187.new/t/valid.t --- Email-Valid-0.187/t/valid.t 2012-01-27 11:27:27.000000000 -0500 +++ Email-Valid-0.187.new/t/valid.t 2012-03-13 19:16:57.119508104 -0400 @@ -1,7 +1,7 @@ #!perl use strict; -use Test::More tests => 31; +use Test::More tests => 33; BEGIN { use_ok('Email::Valid'); @@ -80,6 +80,18 @@ "space between @ and domain is valid", ); +is( + $v->address(-address => '1@example.com', -localpart => 1), + '1@example.com', + "localpart in true context succeeds", +); + +is( + $v->address(-address => '0@example.com', -localpart => 1), + '0@example.com', + "localpart in false context is defined (bug 75736)", +); + ok( $v->address('-dashy@example.net'), 'an email can start with a dash',
merged, released -- rjbs