Bugzilla – Attachment 127522 Details for
Bug 28870
Cart shipping fails because of Non-ASCII characters in display-name of reply-to address
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
21.05.x: Bug 28870: Use Email::Address to validate email addresses
0002-Bug-28870-Use-Email-Address-to-validate-email-addres.patch (text/plain), 2.99 KB, created by
Michael Hafen
on 2021-11-10 23:32:06 UTC
(
hide
)
Description:
21.05.x: Bug 28870: Use Email::Address to validate email addresses
Filename:
MIME Type:
Creator:
Michael Hafen
Created:
2021-11-10 23:32:06 UTC
Size:
2.99 KB
patch
obsolete
>From 6a033e8939cffdcdb9f69b2fccb7650fc41f727f Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 20 Aug 2021 18:23:30 -0300 >Subject: [PATCH 2/6] Bug 28870: Use Email::Address to validate email addresses >Content-Type: text/plain; charset="utf-8" > >This patch adds a new dependency, Email::Address. It is used in >Koha::Email to replace the current use of Email::Valid, which proved to >be problematic when it comes to UTF-8 characters. > >Email::Address provides suitable regexes that -when used- keep our >tests passing, but also deal better with UTF-8 data. > >To test: >1. Apply the regression tests patch >2. Notice the only change is that it tweaks a couple addresses so they > contain umlauts and also have the "Description <address>" format that > is used when sending carts. >3. Run: > $ kshell > k$ prove t/Koha/Email.t >=> FAIL: Tests fail! Things die because Email::Valid doesn't like the > from we passed. >4. Run: > $ sudo apt install libemail-address-perl >5. Apply this patch >6. Repeat 3 >=> SUCCESS: Tests pass! >7. Try what is described in comment 1 >=> SUCCESS: Things are back to normal >8. Sign off :-D >9. Send cookies > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > Koha/Email.pm | 12 +++++------- > 1 file changed, 5 insertions(+), 7 deletions(-) > >diff --git a/Koha/Email.pm b/Koha/Email.pm >index 161848489f..447661264b 100644 >--- a/Koha/Email.pm >+++ b/Koha/Email.pm >@@ -20,7 +20,7 @@ package Koha::Email; > > use Modern::Perl; > >-use Email::Valid; >+use Email::Address; > use Email::MessageID; > use List::Util qw(pairs); > >@@ -78,7 +78,7 @@ sub create { > my $args = {}; > $args->{from} = $params->{from} || C4::Context->preference('KohaAdminEmailAddress'); > Koha::Exceptions::BadParameter->throw("Invalid 'from' parameter: ".$args->{from}) >- unless Email::Valid->address( -address => $args->{from}, -fqdn => 0 ); # from is mandatory >+ unless $args->{from} =~ m/$Email::Address::mailbox/; # from is mandatory > > $args->{subject} = $params->{subject} // ''; > >@@ -90,7 +90,7 @@ sub create { > } > > Koha::Exceptions::BadParameter->throw("Invalid 'to' parameter: ".$args->{to}) >- unless Email::Valid->address( -address => $args->{to}, -fqdn => 0 ); # to is mandatory >+ unless $args->{to} =~ m/$Email::Address::mailbox/; # to is mandatory > > my $addresses = {}; > $addresses->{reply_to} = $params->{reply_to}; >@@ -111,10 +111,8 @@ sub create { > foreach my $address ( keys %{$addresses} ) { > Koha::Exceptions::BadParameter->throw( > "Invalid '$address' parameter: " . $addresses->{$address} ) >- if $addresses->{$address} and !Email::Valid->address( >- -address => $addresses->{$address}, >- -fqdn => 0 >- ); >+ if $addresses->{$address} >+ and $addresses->{$address} !~ m/$Email::Address::mailbox/; > } > > $args->{cc} = $addresses->{cc} >-- >2.25.1 >
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 28870
:
124002
|
124003
|
124004
|
124117
|
124118
|
124119
|
124178
|
124179
|
124180
|
124183
|
124184
|
124185
|
124752
|
124753
|
124754
|
124755
|
124756
|
124757
|
124762
|
124763
|
124764
|
124765
|
124766
|
124767
|
127521
| 127522 |
127523
|
127524
|
127525
|
127526
|
127745
|
127746
|
127747
|
127748
|
127749
|
127750