Lines 665-686
Link Here
|
665 |
# This is the new message. |
665 |
# This is the new message. |
666 |
my $newmsg = ''; |
666 |
my $newmsg = ''; |
667 |
|
667 |
|
|
|
668 |
# the SpamAssassin report |
669 |
my $report = $self->get_report(); |
670 |
|
668 |
# the report charset |
671 |
# the report charset |
669 |
my $report_charset = "; charset=iso-8859-1"; |
672 |
my $report_charset = 'iso-8859-1'; |
670 |
if ($self->{conf}->{report_charset}) { |
673 |
if ($self->{conf}->{report_charset}) { |
671 |
$report_charset = "; charset=" . $self->{conf}->{report_charset}; |
674 |
$report_charset = $self->{conf}->{report_charset}; |
672 |
} |
675 |
} |
673 |
|
676 |
|
674 |
# the SpamAssassin report |
|
|
675 |
my $report = $self->get_report(); |
676 |
|
677 |
# If there are any wide characters, need to MIME-encode in UTF-8 |
677 |
# If there are any wide characters, need to MIME-encode in UTF-8 |
678 |
# TODO: If $report_charset is something other than iso-8859-1/us-ascii, then |
678 |
unless ($] < 5.008) { |
679 |
# we could try converting to that charset if possible |
679 |
use Encode; |
680 |
unless ($] < 5.008 || utf8::downgrade($report, 1)) { |
680 |
my $charset_is_utf8 = 0; |
681 |
$report_charset = "; charset=utf-8"; |
681 |
if ($self->{conf}->{normalize_charset}) { |
682 |
utf8::encode($report); |
682 |
$report = Encode::decode('utf8',$report) unless (Encode::is_utf8($report)); |
|
|
683 |
$charset_is_utf8 = 1; |
684 |
} |
685 |
else { |
686 |
if ($self->{msg}->{charset}) { |
687 |
eval { |
688 |
my $scratch = $report; |
689 |
$report = Encode::decode($self->{msg}->{charset},$scratch,Encode::FB_CROAK); |
690 |
$charset_is_utf8 = 1; |
691 |
}; |
692 |
} |
693 |
} |
694 |
if ($charset_is_utf8) { |
695 |
$charset_is_utf8 = 1; |
696 |
eval { |
697 |
my $scratch = $report; |
698 |
$report = Encode::encode($report_charset,$scratch,Encode::FB_CROAK); |
699 |
$charset_is_utf8 = 0; |
700 |
}; |
701 |
if ($charset_is_utf8) { |
702 |
$report = Encode::encode('utf8',$report); |
703 |
$report_charset = 'utf-8'; |
704 |
} |
705 |
} |
683 |
} |
706 |
} |
|
|
707 |
my $report_charset_param = "; charset=" . $report_charset; |
684 |
|
708 |
|
685 |
# get original headers, "pristine" if we can do it |
709 |
# get original headers, "pristine" if we can do it |
686 |
my $from = $self->{msg}->get_pristine_header("From"); |
710 |
my $from = $self->{msg}->get_pristine_header("From"); |
Lines 798-804
Link Here
|
798 |
This is a multi-part message in MIME format. |
822 |
This is a multi-part message in MIME format. |
799 |
|
823 |
|
800 |
--$boundary |
824 |
--$boundary |
801 |
Content-Type: text/plain$report_charset |
825 |
Content-Type: text/plain$report_charset_param |
802 |
Content-Disposition: inline |
826 |
Content-Disposition: inline |
803 |
Content-Transfer-Encoding: 8bit |
827 |
Content-Transfer-Encoding: 8bit |
804 |
|
828 |
|