From 3b9269d267446a8f2a5a9179079e0a003ed9aff2 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 78b691a..1e4490f 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -538,7 +538,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 2c1ab87..35f5e5a 100755 --- a/misc/cronjobs/runreport.pl +++ b/misc/cronjobs/runreport.pl @@ -34,6 +34,7 @@ use Text::CSV_XS; use CGI qw ( -utf8 ); use Carp; use Encode; +use Email::Valid; use vars qw($VERSION); @@ -212,7 +213,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 cc2a3b9..3e64bea 100755 --- a/opac/opac-sendshelf.pl +++ b/opac/opac-sendshelf.pl @@ -34,6 +34,7 @@ use C4::Output; use C4::Members; use Koha::Email; use Koha::Virtualshelves; +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 8416fbe..926e997 100755 --- a/virtualshelves/sendshelf.pl +++ b/virtualshelves/sendshelf.pl @@ -33,6 +33,7 @@ use C4::Items; use C4::Output; use Koha::Email; use Koha::Virtualshelves; +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; -- 1.9.1