From 6cb9c1ecdc4b4f1e41e22d987fd840aa9b144199 Mon Sep 17 00:00:00 2001 From: mxbeaulieu Date: Mon, 8 Jun 2015 08:34:46 -0400 Subject: [PATCH] Bug 8000 - Updated the remaining email validation to Email::Valid . Replaced the "=~ @" validation with Email::Valid->address(); --- C4/Letters.pm | 1 - basket/sendbasket.pl | 3 ++- misc/cronjobs/runreport.pl | 3 ++- opac/opac-sendbasket.pl | 3 ++- opac/opac-sendshelf.pl | 3 ++- virtualshelves/sendshelf.pl | 3 ++- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index 9f96f6f..ce180d8 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -525,7 +525,6 @@ sub SendAlerts { my $emailsTo = join( ',', @email); my $emailsCC = join( ',', @cc); my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); - # some validation. This could be improved. if ($sendAllEmailsTo && Email::Valid->address($sendAllEmailsTo) ) { $emailsTo = $sendAllEmailsTo; $emailsCC = ''; diff --git a/basket/sendbasket.pl b/basket/sendbasket.pl index 7f6c697..d03edff 100755 --- a/basket/sendbasket.pl +++ b/basket/sendbasket.pl @@ -31,6 +31,7 @@ use C4::Auth; use C4::Output; use C4::Biblio; use Koha::Email; +use Email::Valid; my $query = new CGI; @@ -47,7 +48,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user ( my $bib_list = $query->param('bib_list'); my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); my $email_add = $query->param('email_add'); -$email_add = $sendAllEmailsTo if ($sendAllEmailsTo && $sendAllEmailsTo =~ /@/ ); # some validation. This could be improved. +$email_add = $sendAllEmailsTo if ($sendAllEmailsTo && Email::Valid->address($sendAllEmailsTo) ); my $dbh = C4::Context->dbh; diff --git a/misc/cronjobs/runreport.pl b/misc/cronjobs/runreport.pl index 2958411..401260c 100755 --- a/misc/cronjobs/runreport.pl +++ b/misc/cronjobs/runreport.pl @@ -33,6 +33,7 @@ use Text::CSV_XS; use CGI qw ( -utf8 ); use Carp; use Encode; +use Email::Valid; use vars qw($VERSION); @@ -208,7 +209,7 @@ if ($to or $from or $email) { $to or $to = C4::Context->preference('KohaAdminEmailAddress'); } my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); -$to = $sendAllEmailsTo if ($sendAllEmailsTo && $sendAllEmailsTo =~ /@/ ); # some validation. This could be improved. +$to = $sendAllEmailsTo if ($sendAllEmailsTo && Email::Valid->address($sendAllEmailsTo) ); unless (scalar(@ARGV)) { print STDERR "ERROR: No reportID(s) specified\n"; diff --git a/opac/opac-sendbasket.pl b/opac/opac-sendbasket.pl index dc54525..0783f18 100755 --- a/opac/opac-sendbasket.pl +++ b/opac/opac-sendbasket.pl @@ -34,6 +34,7 @@ use C4::Output; use C4::Biblio; use C4::Members; use Koha::Email; +use Email::Valid; my $query = new CGI; @@ -49,7 +50,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user ( my $bib_list = $query->param('bib_list'); my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); my $email_add = $query->param('email_add'); -$email_add = $sendAllEmailsTo if ($sendAllEmailsTo && $sendAllEmailsTo =~ /@/ ); # some validation. This could be improved. +$email_add = $sendAllEmailsTo if ($sendAllEmailsTo && Email::Valid->address($sendAllEmailsTo) ); my $dbh = C4::Context->dbh; diff --git a/opac/opac-sendshelf.pl b/opac/opac-sendshelf.pl index bb8ae40..db463d8 100755 --- a/opac/opac-sendshelf.pl +++ b/opac/opac-sendshelf.pl @@ -34,6 +34,7 @@ use C4::Output; use C4::VirtualShelves; use C4::Members; use Koha::Email; +use Email::Valid; my $query = new CGI; @@ -49,7 +50,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user ( my $shelfid = $query->param('shelfid'); my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); my $email = $query->param('email'); -$email = $sendAllEmailsTo if ($sendAllEmailsTo && $sendAllEmailsTo =~ /@/ ); # some validation. This could be improved. +$email = $sendAllEmailsTo if ($sendAllEmailsTo && EMail::Valid->address($sendAllEmailsTo) ); my $dbh = C4::Context->dbh; diff --git a/virtualshelves/sendshelf.pl b/virtualshelves/sendshelf.pl index 3de0514..a95f1c6 100755 --- a/virtualshelves/sendshelf.pl +++ b/virtualshelves/sendshelf.pl @@ -33,6 +33,7 @@ use C4::Items; use C4::Output; use C4::VirtualShelves; use Koha::Email; +use Email::Valid; my $query = new CGI; @@ -49,7 +50,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( my $shelfid = $query->param('shelfid'); my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); my $email = $query->param('email'); -$email = $sendAllEmailsTo if ($sendAllEmailsTo && $sendAllEmailsTo =~ /@/ ); # some validation. This could be improved. +$email = $sendAllEmailsTo if ($sendAllEmailsTo && Email::Valid->address($sendAllEmailsTo) ); my $dbh = C4::Context->dbh; -- 2.1.4