From: mkanat%bugzilla.org <> Date: Fri, 14 Dec 2007 11:05:10 +0000 (+0000) Subject: Bug 405362: Bugzilla::Mailer couldn't handle utf-8 strings in the body, because encod... X-Git-Tag: bugzilla-3.1.3~431 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f94214af2e2ec758a0b126aa3ef70be6544aaa9;p=thirdparty%2Fbugzilla.git 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 r=wurblzap, a=mkanat --- diff --git a/Bugzilla/Mailer.pm b/Bugzilla/Mailer.pm index a8ab649136..0040c855eb 100644 --- a/Bugzilla/Mailer.pm +++ b/Bugzilla/Mailer.pm @@ -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); }