2.6.1 已經釋出了,所以提供新的 patch。其實是大同小異的,不過不做新的,我自己做的 ports local/amavisd-new 裝不起來,所以只好先做給它了~
--- amavisd.orig 2008-06-29 08:37:58.000000000 +0800
+++ amavisd 2008-08-21 19:28:52.000000000 +0800
@@ -2026,6 +2026,7 @@
use subs @EXPORT_OK;
use Errno qw(ENOENT EACCES EAGAIN ESRCH);
+use POSIX qw(isprint);
use IO::File ();
use Digest::MD5 2.22; # need 'clone' method
# use Encode; # Perl 5.8 UTF-8 support
@@ -2077,13 +2078,74 @@
}
}
-sub safe_decode($$;$) {
- if (!$unicode_aware) { $_[1] } # just return the second argument
- else {
+sub isbig5($)
+{
+ my $code = shift;
+
+ if (length($code) >= 2)
+ {
+ my @code = split '', $code;
+ if (ord($code[0]) < 161)
+ {
+ return (0);
+ }
+ else
+ {
+ if (((ord($code[1]) >= 64) && (ord($code[1]) <= 126)) ||
+ ((ord($code[1]) >= 161) && (ord($code[1]) <= 254)))
+ {
+ return (1);
+ }
+ }
+ }
+ return (0);
+}
+
+sub isbig5str($)
+{
+ my $astr = shift;
+ my $alen = length($astr);
+ my $rlen = 0;
+
+ while ($rlen < $alen)
+ {
+ if (isbig5(substr($astr, $rlen, $alen - $rlen)))
+ {
+ $rlen += 2;
+ }
+ elsif (isprint(substr($astr, $rlen, 1)))
+ {
+ $rlen += 1;
+ }
+ else
+ {
+ return (0);
+ }
+ }
+ return (1);
+}
+
+sub safe_decode($$;$)
+{
+ if (!$unicode_aware)
+ {
+ $_[1];
+ } # just return the second argument
+ else
+ {
my($encoding,$str,$check) = @_;
- $check = 0 if !defined($check);
- my($taint) = substr($str,0,0); # taintedness of the string
- $taint . Encode::decode($encoding,untaint($str),$check); # preserve taint
+ $check = 0 if !defined($check);
+ my($taint) = substr($str,0,0); # taintedness of the string
+ my($u_str) = untaint($str);
+ my($d_str) = $taint . Encode::decode($encoding,$u_str,$check); # preserve
+ if (($d_str eq $u_str) && isbig5str($u_str))
+ {
+ $taint . Encode::decode("big5",$u_str,$check)
+ }
+ else
+ {
+ $d_str;
+ }
}
}
@@ -12554,7 +12616,7 @@
Amavis::Lookup::RE->new(@$Amavis::Conf::map_full_type_to_short_type_re);
# default location of the config file if none specified
-push(@config_files, '/etc/amavisd.conf') if !@config_files;
+push(@config_files, '/usr/local/etc/amavisd.conf') if !@config_files;
# Read and evaluate config files, which may override default settings
Amavis::Conf::include_config_files(@config_files);
Amavis::Conf::supply_after_defaults();