diff --git a/6.1.22/patches/09_1913_email_validation.patch b/6.1.22/patches/09_1913_email_validation.patch new file mode 100644 index 0000000000000000000000000000000000000000..dd85cd91e0af203c9c08e69ecb7c2f7009f939ca --- /dev/null +++ b/6.1.22/patches/09_1913_email_validation.patch @@ -0,0 +1,83 @@ +diff --git a/sympa-6.1.22-src/src/lib/List.pm b/sympa-6.1.22-src/src/lib/List.pm +index ca917d4..c0fb591 100644 +--- a/sympa-6.1.22-src/src/lib/List.pm ++++ b/sympa-6.1.22-src/src/lib/List.pm +@@ -7519,7 +7519,7 @@ sub add_user { + + foreach my $new_user (@new_users) { + my $who = &tools::clean_email($new_user->{'email'}); +- unless ($who) { ++ unless ($who || ! &tools::valid_email($new_user->{'email'})) { + Log::do_log('err', 'Ignoring %s which is not a valid email',$new_user->{'email'}); + next; + } +diff --git a/sympa-6.1.22-src/src/lib/confdef.pm b/sympa-6.1.22-src/src/lib/confdef.pm +index 0dbb4e8..7b471dc 100644 +--- a/sympa-6.1.22-src/src/lib/confdef.pm ++++ b/sympa-6.1.22-src/src/lib/confdef.pm +@@ -1564,6 +1564,13 @@ our @params = ( + 'edit' => '1', + 'file' => 'sympa.conf', + }, ++ { ++ 'name' => 'email_validation', ++ 'query' => 'The email validation techniques to be used against email addresses that are added to mailing lists. Options come from Email::Validate (http://search.cpan.org/~rjbs/Email-Valid-1.194/lib/Email/Valid.pm). Commenting this out turns off email validation.', ++ 'default' => 'tldcheck,fqdn,rfc822', ++ 'edit' => '1', ++ 'file' => 'sympa.conf', ++ }, + + ## Not implemented yet. + ## { +diff --git a/sympa-6.1.22-src/src/lib/tools.pm b/sympa-6.1.22-src/src/lib/tools.pm +index d9be037..37bd999 100644 +--- a/sympa-6.1.22-src/src/lib/tools.pm ++++ b/sympa-6.1.22-src/src/lib/tools.pm +@@ -2746,6 +2746,30 @@ sub valid_email { + return undef; + } + ++ # If email_validation is set then apply additional email validation set ++ # by Email::Valid as per the configuration ++ if ($Conf::Conf{'email_validation'}) { ++ use Email::Valid; ++ my $technique_map = { ++ 'tldcheck' => '-tldcheck', ++ 'fqdn' => '-fqdn', ++ 'mxcheck' => '-mxcheck', ++ 'fudge' => '-fudge', ++ 'allow_ip' => '-allow_ip', ++ 'local_rules' => '-local_rules' ++ }; ++ my @techniques = split(',', $Conf::Conf{'email_validation'}); ++ my @options; ++ foreach (@techniques) { ++ push @options, $technique_map->{$_}; ++ } ++ my $valid = new Email::Valid(@options); ++ if (!$valid->address($email)) { ++ do_log('err', "Invalid email address '%s' [%s]", $email, $valid->details()); ++ return undef; ++ } ++ } ++ + return 1; + } + +diff --git a/sympa-6.1.22-src/src/sympa_wizard.pl.in b/sympa-6.1.22-src/src/sympa_wizard.pl.in +index 0d4789d..cb886fd 100644 +--- a/sympa-6.1.22-src/src/sympa_wizard.pl.in ++++ b/sympa-6.1.22-src/src/sympa_wizard.pl.in +@@ -380,6 +380,12 @@ sub check_cpan { + mandatory => 1, + usage => 'module for character encoding processing', + }, ++ 'Email::Valid' => { ++ required_version =>'1.194', ++ package_name => 'Email-Valid', ++ mandatory => 1, ++ usage => 'used to compute validate email addresses', ++ }, + 'FCGI' => { + required_version => '0.67', + package_name => 'FCGI', diff --git a/6.1.22/patches/README b/6.1.22/patches/README index ccce8d619c68b4e66a27fec79fc72cc0f0bc0cd0..58537313fa43ef7defc84b5c1d2dc6520012f239 100644 --- a/6.1.22/patches/README +++ b/6.1.22/patches/README @@ -37,3 +37,7 @@ This fixes a bug in the init script for Debian Wheezy systems 08_2821_max_list_dispatch.patch ------------------------------- Adds a feature to set hard limits on the size of lists that can send mail. This is controlled by max_list_dispatch and max_list_dispatch_from_subscriber. See https://labs.riseup.net/code/issues/2821 for more info. + +09_1913_email_validation.patch +------------------------------ +Adds configureable email validations provided by Email::Valid. See https://labs.riseup.net/code/issues/1913 for more info. diff --git a/sympa-6.1.22-src/src/lib/List.pm b/sympa-6.1.22-src/src/lib/List.pm index ca917d43672428744e71599b63d24d50a3a09984..c0fb591b120880c23608b67d694c37501a8c9122 100644 --- a/sympa-6.1.22-src/src/lib/List.pm +++ b/sympa-6.1.22-src/src/lib/List.pm @@ -7519,7 +7519,7 @@ sub add_user { foreach my $new_user (@new_users) { my $who = &tools::clean_email($new_user->{'email'}); - unless ($who) { + unless ($who || ! &tools::valid_email($new_user->{'email'})) { Log::do_log('err', 'Ignoring %s which is not a valid email',$new_user->{'email'}); next; } diff --git a/sympa-6.1.22-src/src/lib/confdef.pm b/sympa-6.1.22-src/src/lib/confdef.pm index 0dbb4e877d223719815e09631b08f319d5b54e62..7b471dc1a97a53f4a7384f3212083a26231f0bc8 100644 --- a/sympa-6.1.22-src/src/lib/confdef.pm +++ b/sympa-6.1.22-src/src/lib/confdef.pm @@ -1564,6 +1564,13 @@ our @params = ( 'edit' => '1', 'file' => 'sympa.conf', }, + { + 'name' => 'email_validation', + 'query' => 'The email validation techniques to be used against email addresses that are added to mailing lists. Options come from Email::Validate (http://search.cpan.org/~rjbs/Email-Valid-1.194/lib/Email/Valid.pm). Commenting this out turns off email validation.', + 'default' => 'tldcheck,fqdn,rfc822', + 'edit' => '1', + 'file' => 'sympa.conf', + }, ## Not implemented yet. ## { diff --git a/sympa-6.1.22-src/src/lib/tools.pm b/sympa-6.1.22-src/src/lib/tools.pm index d9be037926946c4f617f556bea1187e37258200b..37bd999aadb2c13ae739c4047f70c84484a9923f 100644 --- a/sympa-6.1.22-src/src/lib/tools.pm +++ b/sympa-6.1.22-src/src/lib/tools.pm @@ -2746,6 +2746,30 @@ sub valid_email { return undef; } + # If email_validation is set then apply additional email validation set + # by Email::Valid as per the configuration + if ($Conf::Conf{'email_validation'}) { + use Email::Valid; + my $technique_map = { + 'tldcheck' => '-tldcheck', + 'fqdn' => '-fqdn', + 'mxcheck' => '-mxcheck', + 'fudge' => '-fudge', + 'allow_ip' => '-allow_ip', + 'local_rules' => '-local_rules' + }; + my @techniques = split(',', $Conf::Conf{'email_validation'}); + my @options; + foreach (@techniques) { + push @options, $technique_map->{$_}; + } + my $valid = new Email::Valid(@options); + if (!$valid->address($email)) { + do_log('err', "Invalid email address '%s' [%s]", $email, $valid->details()); + return undef; + } + } + return 1; } diff --git a/sympa-6.1.22-src/src/sympa_wizard.pl.in b/sympa-6.1.22-src/src/sympa_wizard.pl.in index 0d4789d4b25825201a39eb516c25a6485dcb2ec4..cb886fd3548319e158182af7b9d2e7059f11bc28 100644 --- a/sympa-6.1.22-src/src/sympa_wizard.pl.in +++ b/sympa-6.1.22-src/src/sympa_wizard.pl.in @@ -380,6 +380,12 @@ sub check_cpan { mandatory => 1, usage => 'module for character encoding processing', }, + 'Email::Valid' => { + required_version =>'1.194', + package_name => 'Email-Valid', + mandatory => 1, + usage => 'used to compute validate email addresses', + }, 'FCGI' => { required_version => '0.67', package_name => 'FCGI',