From 6deb7dbaa46e4c04a7fe372bd4faf04f2b679d31 Mon Sep 17 00:00:00 2001 From: Thomas Hochstein Date: Sat, 29 May 2021 09:47:17 +0200 Subject: [PATCH 1/2] Add MID to error message to make it more useful. Signed-off-by: Thomas Hochstein --- bin/parsedb.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/parsedb.pl b/bin/parsedb.pl index b4c2056..a5b2ce8 100755 --- a/bin/parsedb.pl +++ b/bin/parsedb.pl @@ -258,9 +258,9 @@ while (my $HeadersR = $DBQuery->fetchrow_hashref) { split(/ /,'? ' x scalar(@DBFields))) )); $DBWrite->execute(@SQLBindVars) - or &Bleat(2,sprintf("Can't write parsed data for %s to %s.%s: ". + or &Bleat(2,sprintf("Can't write parsed data for %s to %s.%s for %s: ". "$DBI::errstr\n",$Period, - $Conf{'DBDatabase'},$Conf{'DBTableParse'})); + $Conf{'DBDatabase'},$Conf{'DBTableParse'}, $Headers{'mid'})); $DBWrite->finish; } }; From b99d41010ddffd330464c6a80da615c232b2832e Mon Sep 17 00:00:00 2001 From: Thomas Hochstein Date: Sat, 29 May 2021 10:17:00 +0200 Subject: [PATCH 2/2] Forcibly decode headers with unencoded 8bit chars. Just assume UTF-8 for the time being. Fixes database errors with illegal characters when writing parsed data. Signed-off-by: Thomas Hochstein --- bin/parsedb.pl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bin/parsedb.pl b/bin/parsedb.pl index a5b2ce8..8004cb1 100755 --- a/bin/parsedb.pl +++ b/bin/parsedb.pl @@ -198,6 +198,11 @@ while (my $HeadersR = $DBQuery->fetchrow_hashref) { $Headers{$HeaderName.'_parsed'} = decode('MIME-Header',$Headers{$_}) if (exists($LegalEncodings{$Encoding})); } + # forcibly modify headers with un-encoded 8bit data assuming utf-8 + # TODO: try to guess correct enconding + elsif ($Headers{$_} =~ /[^\x00-\x7F]/) { + $Headers{$_} = decode('utf-8',$Headers{$_}); + } # extract name(s) and mail(s) from From: / Sender: / Reply-To: # in parsed form, if available if ($_ ne 'subject') {