[Mimedefang] utf-8 issue?

Benoit Panizzon benoit.panizzon at imp.ch
Thu Jan 30 03:41:40 EST 2020


I suppose I came over a very similar issue while building an spamtrap
which extracts attachements with MIME::Parser and feeds them down the
throat of clamav.

It boils more or down how perl threat UTF-8 strings on file functions
and how posix systems don't care about the encoding of filenames

What I found out to work with try and error, still not sure why:

use utf8;
use open ':std', ':encoding(UTF-8)';


my $filename     = $part->head->recommended_filename;

print SPAMFILE $attachment;

if (utf8::is_utf8($filename)) {
     print "Filename IS UTF8, encode Filename for AV\n";
     utf8::encode($filename); # This encodes UTF-8 Perl Strings to binary string.

my ($path,$found) = $av->scan_path("$spamdir/$filename"); # Now Umlauts and similar characters in the filename do not cause the file not to be found.

Mit freundlichen Grüssen

-Benoît Panizzon-
I m p r o W a r e   A G    -    Leiter Commerce Kunden

Zurlindenstrasse 29             Tel  +41 61 826 93 00
CH-4133 Pratteln                Fax  +41 61 826 93 01
Schweiz                         Web  http://www.imp.ch

More information about the MIMEDefang mailing list