Bugzilla – Attachment 40227 Details for
Bug 8000
Test mode for notices
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8000 - Validate allEmailsTo email address before using it
Bug-8000---Validate-allEmailsTo-email-address-befo.patch (text/plain), 3.31 KB, created by
Mark Tompsett
on 2015-06-17 11:09:29 UTC
(
hide
)
Description:
Bug 8000 - Validate allEmailsTo email address before using it
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2015-06-17 11:09:29 UTC
Size:
3.31 KB
patch
obsolete
>From 991580546397c5f0b291cfbc6de3151fcf39f887 Mon Sep 17 00:00:00 2001 >From: Blou <philippe.blouin@inlibro.com> >Date: Fri, 7 Mar 2014 13:31:30 -0500 >Subject: [PATCH] Bug 8000 - Validate allEmailsTo email address before using it > >This patch adds Data::Validate::Email to validate the "allEmailsTo" address >before using it as a unique destination. >Added to PerlDependencies.pm for this and future potential usages. >--- > C4/Installer/PerlDependencies.pm | 5 +++++ > C4/Letters.pm | 9 +++++---- > 2 files changed, 10 insertions(+), 4 deletions(-) > >diff --git a/C4/Installer/PerlDependencies.pm b/C4/Installer/PerlDependencies.pm >index 57c5972..36d097b 100644 >--- a/C4/Installer/PerlDependencies.pm >+++ b/C4/Installer/PerlDependencies.pm >@@ -737,6 +737,11 @@ our $PERL_DEPS = { > 'required' => '0', > 'min_ver' => '0.89', > }, >+ 'Data::Validate::Email' => { >+ 'usage' => 'Email validation', >+ 'required' => '1', >+ 'min_ver' => '0.04', >+ }, > }; > > 1; >diff --git a/C4/Letters.pm b/C4/Letters.pm >index d240c8a..bcf0a49 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -35,6 +35,7 @@ use Date::Calc qw( Add_Delta_Days ); > use Encode; > use Carp; > use Koha::Email; >+use Data::Validate::Email qw(is_email); > > use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); > >@@ -406,7 +407,7 @@ sub SendAlerts { > my $borinfo = C4::Members::GetMember('borrowernumber' => $_->{'borrowernumber'}); > my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); > my $email = $sendAllEmailsTo; >- if (!($sendAllEmailsTo && $sendAllEmailsTo =~ /@/) ){ # some validation. This could be improved. >+ if (!($sendAllEmailsTo && is_email($sendAllEmailsTo))){ > $email = $borinfo->{email} or next; > } > >@@ -525,7 +526,7 @@ sub SendAlerts { > my $emailsCC = join( ',', @cc); > my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); > # some validation. This could be improved. >- if ($sendAllEmailsTo && $sendAllEmailsTo =~ /@/ ) { >+ if ($sendAllEmailsTo && is_email($sendAllEmailsTo) ) { > $emailsTo = $sendAllEmailsTo; > $emailsCC = ''; > } >@@ -585,7 +586,7 @@ sub SendAlerts { > my $email = Koha::Email->new(); > my $emailaddr = $externalid->{'emailaddr'}; > my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); >- $emailaddr = $sendAllEmailsTo if ($sendAllEmailsTo && $sendAllEmailsTo =~ /@/ ); # some validation. This could be improved. >+ $emailaddr = $sendAllEmailsTo if ($sendAllEmailsTo && is_email($sendAllEmailsTo) ); > my %mail = $email->create_message_headers( > { > to => $emailaddr, >@@ -1154,7 +1155,7 @@ sub _send_message_by_email { > $to_address = C4::Members::GetNoticeEmailAddress( $message->{'borrowernumber'} ); > } > my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); >- $to_address = $sendAllEmailsTo if ($sendAllEmailsTo && $sendAllEmailsTo =~ /@/ ); # some validation. This could be improved. >+ $to_address = $sendAllEmailsTo if ($sendAllEmailsTo && is_email($sendAllEmailsTo) ); > unless ($to_address) { > if (!$member) { > warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})"; >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8000
:
21976
|
22315
|
24784
|
25917
|
25919
|
25920
|
25923
|
25924
|
25925
|
25926
|
25927
|
25928
|
25939
|
25950
|
25951
|
26446
|
37463
|
37464
|
37465
|
37466
|
37467
|
37468
|
37469
|
37472
|
37473
|
37474
|
37475
|
37476
|
37477
|
37478
|
37481
|
37482
|
37483
|
37484
|
37485
|
37486
|
37487
|
39985
|
39986
|
39987
|
39988
|
39989
|
39990
|
39991
|
39992
|
40215
|
40216
|
40217
|
40218
|
40219
|
40220
|
40221
|
40222
|
40223
|
40224
|
40225
|
40226
|
40227
|
40228
|
40229
|
40230
|
46354
|
46355
|
46356
|
46357
|
46358
|
46359
|
46360
|
46361
|
46362
|
49991
|
49992
|
49993
|
49998
|
49999
|
50000
|
55940
|
58434
|
62863
|
67155
|
70086
|
70087
|
70484
|
74110
|
74111
|
74848
|
80370
|
81487
|
81488
|
81589
|
81590
|
81591
|
84801
|
84802
|
84803
|
84804
|
84805
|
86861
|
86862
|
86863
|
86864
|
86865
|
88874
|
88875
|
88876
|
88877
|
88878
|
88879