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: 74055
Status: resolved
Priority: 0/
Queue: Email-Valid

People
Owner: Nobody in particular
Requestors: fbergo [...] gmail.com
Cc:
AdminCc:

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



Subject: bug report + fix in Email::Valid
Date: Tue, 17 Jan 2012 05:59:09 -0200
To: bug-Email-Valid [...] rt.cpan.org
From: Felipe Bergo <fbergo [...] gmail.com>
Report: in the current version (0.185) of Email::Valid, it uses an eval block to call the isa() method on a scalar that may not be an object. Under most circumstances, this will cause no visible errors, but when SIG{"__DIE__"} is assigned to a custom subroutine, the error in the eval block will still be caught, when no error should be generated/reported. Such invalid call to isa() seems to occur only when the username or the domain part starts with digits (such as 123@abc.com or abc@123.com) and the mxcheck option is enabled. I have fixed this by replacing the eval blocks with a preliminary verification call to Scalar::Util's blessed(). Patch against 0.185 (also attached as Valid.patch): --- Valid.bk    2012-01-17 05:01:42.151395489 -0200 +++ Valid.pm    2012-01-17 05:01:38.353394919 -0200 @@ -10,6 +10,7 @@  use IO::File;  use Mail::Address;  use File::Spec; +use Scalar::Util 'blessed';  use bytes; @@ -102,7 +103,7 @@    my %args = $self->_rearrange([qw( address )], \@_);    my $addr = $args{address} or return $self->details('rfc822'); -  $addr = $addr->address if eval { $addr->isa('Mail::Address') }; +  $addr = $addr->address if (blessed($addr) && $addr->isa('Mail::Address'));    return $self->details('rfc822')      if $addr =~ /\P{ASCII}/ or $addr !~ m/^$RFC822PAT$/o; @@ -234,7 +235,7 @@    my $self = shift;    my $addr = shift; -  $addr = $addr->address if eval { $addr->isa('Mail::Address') }; +  $addr = $addr->address if (blessed($addr) && $addr->isa('Mail::Address'));    my $host = ($addr =~ /^.*@(.*)$/ ? $1 : $addr);    $host =~ s/\s+//g; @@ -312,7 +313,7 @@                                      local_rules )], \@_);    my $addr = $args{address} or return $self->details('rfc822'); -  $addr = $addr->address if eval { $addr->isa('Mail::Address') }; +  $addr = $addr->address if (blessed($addr) && $addr->isa('Mail::Address'));    $addr = $self->_fudge( $addr ) if $args{fudge};    $self->rfc822( -address => $addr ) or return undef; Test script (attached as email.pl): #!/usr/bin/perl -Tw use strict; require Email::Valid; $SIG{"__DIE__"} = sub {     my $why = shift;     print "caught error: $why"; }; my @test = ('normal@normal.com','clearly invalid','123@abc.com','abc@123.com','123@123.com'); foreach (@test) {     print "test case $_ : ";         if (Email::Valid->address( -address => $_, -mxcheck => 1))     { print "valid\n"; } else { print "invalid\n"; } } # end of test script Output on current version (0.185): test case normal@normal.com : valid test case clearly invalid : invalid test case 123@abc.com : caught error: Can't call method "isa" without a package or object reference at /usr/lib/perl5/site_perl/5.8.8/Email/Valid.pm line 315. caught error: Can't call method "isa" without a package or object reference at /usr/lib/perl5/site_perl/5.8.8/Email/Valid.pm line 105. valid test case abc@123.com : caught error: Can't call method "isa" without a package or object reference at /usr/lib/perl5/site_perl/5.8.8/Email/Valid.pm line 237. valid test case 123@123.com : caught error: Can't call method "isa" without a package or object reference at /usr/lib/perl5/site_perl/5.8.8/Email/Valid.pm line 315. caught error: Can't call method "isa" without a package or object reference at /usr/lib/perl5/site_perl/5.8.8/Email/Valid.pm line 105. caught error: Can't call method "isa" without a package or object reference at /usr/lib/perl5/site_perl/5.8.8/Email/Valid.pm line 237. valid Output after application of patch: test case normal@normal.com : valid test case clearly invalid : invalid test case 123@abc.com : valid test case abc@123.com : valid test case 123@123.com : valid System information: Module version: Email::Valid 0.185 PERL version: This is perl 5, version 12, subversion 4 (v5.12.4) built for x86_64-linux-thread-multi Operating system: Linux x86_64 (Fedora 14) uname -a: Linux sandman 2.6.35.14-100.fc14.x86_64 #1 SMP Fri Oct 21 18:40:08 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux Best regards, -- Felipe Bergo

Message body is not shown because sender requested not to inline it.

Message body is not shown because sender requested not to inline it.

change made, released -- rjbs