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;
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);
' 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',