diff --git a/lib/WebGUI/Account/Inbox.pm b/lib/WebGUI/Account/Inbox.pm index 2eecedc2d..952613c31 100644 --- a/lib/WebGUI/Account/Inbox.pm +++ b/lib/WebGUI/Account/Inbox.pm @@ -8,6 +8,7 @@ use WebGUI::International; use WebGUI::Pluggable; use WebGUI::Utility; use Tie::IxHash; +use Email::Valid; use base qw/WebGUI::Account/; =head1 NAME @@ -908,7 +909,7 @@ sub www_inviteUserSave { my $db = $session->db; my @toList = split /[;,]/, $to; for my $inviteeEmail (@toList) { - unless ( $inviteeEmail =~ WebGUI::Utility::emailRegex ) { + unless ( Email::Valid->address($inviteeEmail) ) { return $self->www_inviteUser( sprintf $i18n->get('invalid email'), $inviteeEmail ); } diff --git a/lib/WebGUI/Form/Email.pm b/lib/WebGUI/Form/Email.pm index 907796d2f..97416c62d 100644 --- a/lib/WebGUI/Form/Email.pm +++ b/lib/WebGUI/Form/Email.pm @@ -18,6 +18,7 @@ use strict; use base 'WebGUI::Form::Text'; use WebGUI::International; use WebGUI::Utility; +use Email::Valid; =head1 NAME @@ -66,7 +67,7 @@ An optional value to process instead of POST input. sub getValue { my $self = shift; my $value = @_ ? shift : $self->session->form->param($self->get("name")); - if ($value =~ WebGUI::Utility::emailRegex) { + if (Email::Valid->address($value)) { return $value; } return undef; diff --git a/lib/WebGUI/Utility.pm b/lib/WebGUI/Utility.pm index 20461874e..044ab2f91 100644 --- a/lib/WebGUI/Utility.pm +++ b/lib/WebGUI/Utility.pm @@ -57,20 +57,6 @@ These subroutines are available from this package: =cut - -#------------------------------------------------------------------- - -=head2 emailRegex ( ) - -Returns a regex object that can be used to validate email addresses. - -=cut - -sub emailRegex { - return qr/^([0-9a-zA-Z]+[-._+&])*\w+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,7}$/; -} - - #------------------------------------------------------------------- =head2 isBetween ( value, first, second ) diff --git a/sbin/testEnvironment.pl b/sbin/testEnvironment.pl index a9052a142..c0a4b1158 100755 --- a/sbin/testEnvironment.pl +++ b/sbin/testEnvironment.pl @@ -157,6 +157,7 @@ checkModule('Package::Stash', ); checkModule('HTTP::Exception', ); checkModule('Net::Twitter', "3.13006" ); checkModule('Number::Format', ); +checkModule('Email::Valid', ); failAndExit("Required modules are missing, running no more checks.") if $missingModule; diff --git a/t/Utility.t b/t/Utility.t index 3c5892c39..259366164 100644 --- a/t/Utility.t +++ b/t/Utility.t @@ -165,14 +165,6 @@ is(WebGUI::Utility::isInSubnet('192.168.0.1', ['192.257.0.1/32']), undef, 'isInS is(WebGUI::Utility::isInSubnet('192.168.0.1', ['192.168.258.1/32']), undef, 'isInSubnet: ip has an out of range quad'); is(WebGUI::Utility::isInSubnet('192.168.0.1', ['192.168.0.259/32']), undef, 'isInSubnet: ip has an out of range quad'); -##################################################################### -# -# emailRegex -# -##################################################################### - -isa_ok(WebGUI::Utility::emailRegex, 'Regexp'); - TODO: { local $TODO = 'Things to do'; ok(0, 'Move email validation tests out of Form/Email into here');