From: Mark M. <Mar...@ij...> - 2011-01-28 00:45:31
|
In January 2011 a version 5.500 of a perl module MIME-Tools was released. This module is used by amavisd for decoding a MIME structure of a mail message. The version 5.500 changed a type of a result returned by methods mime_attr() and recommended_filename() of a header object: previously attributes of MIME subheader fields (such as a suggested file name for storing an attachment) were returned in a MIME-encoded form, but since the version 5.500 they are returned as decoded string as native perl characters (Unicode). Such names are used by amavisd in its banning rules and in logging. As these attributes were previously provided in an encoded form, amavisd attempts to decode them by calling MIME::Words::decode_mimewords. With a change of the result type the call to decode_mimewords is now redundant, and can result in a voluntary termination in decode_mimewords, thus prohibiting further mail decoding and a subsequent temporary failure for messages with certain UTF-8 encoded names of attachments. The following patch fixes the problem for amavisd-new-2.6.4, making it compatible with MIME-Tools 5.500 as well as its predecessors. It is likely it will remain compatible with a successor of 5.500, although the fate of this change in MIME-Tools has not been irrevocably decided yet. An equivalent fix can be made to 2.7.0-pre13, although the patch below does not apply cleanly, but will be incorporated in the next pre-release. There are some related concerns with version 5.500 of MIME-Tools: http://rt.cpan.org/Ticket/Display.html?id=65162 so if you have a choice, don't rush with upgrading to 5.500. Thanks to Dario Palmisano for reporting the problem and testing a solution, and to David F. Skoll for a quick response. --- amavisd~ 2011-01-27 02:48:43.238780803 +0100 +++ amavisd 2011-01-27 02:50:56.922880705 +0100 @@ -7356,15 +7356,20 @@ my(@rn); # recommended file names, both raw and RFC 2047 decoded my($val, $val_decoded); + my($mimetools_v) = MIME::Head->VERSION; $val = $head->mime_attr('content-disposition.filename'); if ($val ne '') { push(@rn, $val); - $val_decoded = MIME::Words::decode_mimewords($val); - push(@rn, $val_decoded) if $val_decoded ne $val; + if ($mimetools_v < 5.500) { + $val_decoded = MIME::Words::decode_mimewords($val); + push(@rn, $val_decoded) if $val_decoded ne $val; + } } $val = $head->mime_attr('content-type.name'); if (defined($val) && $val ne '') { - $val_decoded = MIME::Words::decode_mimewords($val); - push(@rn, $val_decoded) if !grep { $_ eq $val_decoded } @rn; - push(@rn, $val) if !grep { $_ eq $val } @rn; + if ($mimetools_v < 5.500) { + $val_decoded = MIME::Words::decode_mimewords($val); + push(@rn, $val_decoded) if !grep { $_ eq $val_decoded } @rn; + } + push(@rn, $val) if !grep { $_ eq $val } @rn; } $part->name_declared(@rn==1 ? $rn[0] : \@rn) if @rn; Mark |