]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 405362: Bugzilla::Mailer couldn't handle utf-8 strings in the body, because encod...
authormkanat%bugzilla.org <>
Fri, 14 Dec 2007 11:05:10 +0000 (11:05 +0000)
committermkanat%bugzilla.org <>
Fri, 14 Dec 2007 11:05:10 +0000 (11:05 +0000)
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=wurblzap, a=mkanat

Bugzilla/Mailer.pm

index a8ab649136ce2edd4d97b91a2b5a4b3fe3ead1fb..0040c855ebb779eb0d732215cbe995cb207199f2 100644 (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);
     }