From: Sven Schöling Date: Mon, 15 Jul 2019 18:12:27 +0000 (+0200) Subject: Mailer: Bei fehlerhaften Mailadressen warnen X-Git-Tag: kivitendo-mebil_0.1-0~10^2~2^2~355 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=2bceb436f4f68179d8b380f75331b15d2ebe5737;p=kivitendo-erp.git Mailer: Bei fehlerhaften Mailadressen warnen (cherry picked from commit e8f152b186583bc254ff631f4803189da4f3013e) (cherry-pick von odyn) --- diff --git a/SL/Mailer.pm b/SL/Mailer.pm index a408b03b9..f242120a9 100644 --- a/SL/Mailer.pm +++ b/SL/Mailer.pm @@ -29,11 +29,13 @@ use Encode; use File::MimeInfo::Magic; use File::Slurp; use List::UtilsBy qw(bundle_by); +use List::Util qw(sum); use SL::Common; use SL::DB::EmailJournal; use SL::DB::EmailJournalAttachment; use SL::DB::Employee; +use SL::Locale::String qw(t8); use SL::Template; use SL::Version; @@ -121,8 +123,21 @@ sub _create_address_headers { next if !$self->{$item}; my @header_addresses; + my @addresses = Email::Address->parse($self->{$item}); + + # if either no address was parsed or + # there are more than 3 characters per parsed email extra, assume the the user has entered bunk + if (!@addresses) { + die t8('"#1" seems to be a faulty list of email addresses. No addresses could be extracted.', + $self->{$item}, + ); + } elsif ((length($self->{$item}) - sum map { length $_->original } @addresses) / @addresses > 3) { + die t8('"#1" seems to be a faulty list of email addresses. After extracing addresses (#2) too many characters are left.', + $self->{$item}, join ', ', map { $_->original } @addresses, + ); + } - foreach my $addr_obj (Email::Address->parse($self->{$item})) { + foreach my $addr_obj (@addresses) { push @{ $self->{addresses}->{$item} }, $addr_obj->address; next if $self->{driver}->keep_from_header($item); diff --git a/locale/de/all b/locale/de/all index 25c15a7a0..3af730bbc 100755 --- a/locale/de/all +++ b/locale/de/all @@ -13,6 +13,8 @@ $self->{texts} = { ' Date missing!' => ' Datum fehlt!', ' bytes, max=' => ' Bytes, Maximum=', ' missing!' => ' fehlt!', + '"#1" seems to be a faulty list of email addresses. After extracing addresses (#2) too many characters are left.' => '"#1" scheint fehlerhaft zu sein. Es wurden E-Mail Adressen extrahiert (#2), aber es sind noch zu viele Zeichen übrig.', + '"#1" seems to be a faulty list of email addresses. No addresses could be extracted.' => '"#1" scheint fehlerhaft zu sein. Es konnte keine E-Mail Adresse extrahiert werden', '#1 (custom variable)' => '#1 (benutzerdefinierte Variable)', '#1 MD' => '#1 PT', '#1 additional part(s)' => '#1 zusätzliche(r) Artikel',