Bug 405362: Bugzilla::Mailer couldn't handle utf-8 strings in the body, because encoding_set doesn't understand utf8 perl strings.

Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=wurblzap, a=mkanat


git-svn-id: svn://10.0.0.236/trunk@241221 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mkanat%bugzilla.org 2007-12-14 05:05:10 +00:00
parent 45ec8db5b3
commit b3bb8043bf

View File

@ -57,7 +57,15 @@ sub MessageToMTA {
my $email = ref($msg) ? $msg : Email::MIME->new($msg);
foreach my $part ($email->parts) {
$part->charset_set('UTF-8') if Bugzilla->params->{'utf8'};
if (Bugzilla->params->{'utf8'}) {
$part->charset_set('UTF-8');
# encoding_set works only with bytes, not with utf8 strings.
my $raw = $part->body_raw;
if (utf8::is_utf8($raw)) {
utf8::encode($raw);
$part->body_set($raw);
}
}
$part->encoding_set('quoted-printable') if !is_7bit_clean($part->body);
}