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>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
use Email::MessageID;
use List::Util qw( pairs );
use Email::MessageID;
use List::Util qw( pairs );
my $args = {};
$args->{from} = $params->{from} || C4::Context->preference('KohaAdminEmailAddress');
Koha::Exceptions::BadParameter->throw("Invalid 'from' parameter: ".$args->{from})
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} // '';
$args->{subject} = $params->{subject} // '';
}
Koha::Exceptions::BadParameter->throw("Invalid 'to' parameter: ".$args->{to})
}
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};
my $addresses = {};
$addresses->{reply_to} = $params->{reply_to};
foreach my $address ( keys %{$addresses} ) {
Koha::Exceptions::BadParameter->throw(
"Invalid '$address' parameter: " . $addresses->{$address} )
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}
}
$args->{cc} = $addresses->{cc}
requires 'DateTime::TimeZone', '1.20';
requires 'Digest::MD5', '2.36';
requires 'Digest::SHA', '5.43';
requires 'DateTime::TimeZone', '1.20';
requires 'Digest::MD5', '2.36';
requires 'Digest::SHA', '5.43';
+requires 'Email::Address', '>= 1.908';
requires 'Email::Date', '1.103';
requires 'Email::MessageID', '1.406';
requires 'Email::Sender', '1.300030';
requires 'Email::Date', '1.103';
requires 'Email::MessageID', '1.406';
requires 'Email::Sender', '1.300030';