]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Backing out Bug 714724
authorByron Jones <bjones@mozilla.com>
Wed, 25 Jan 2012 07:14:48 +0000 (15:14 +0800)
committerByron Jones <bjones@mozilla.com>
Wed, 25 Jan 2012 07:14:48 +0000 (15:14 +0800)
Bugzilla/Mailer.pm

index 1e40794887a83d457a5e327321d4bac91bdbea5b..10a456dd6ea3acab94ea1fc867c172b573b1136d 100644 (file)
@@ -83,16 +83,6 @@ sub MessageToMTA {
         }
     }
 
-    $email->walk_parts(sub {
-        my ($part) = @_;
-        return if $part->parts > 1; # Top-level
-        my $content_type = $part->content_type || '';
-        if ($content_type !~ /;/) {
-            $part->charset_set('UTF-8') if Bugzilla->params->{'utf8'};
-            $part->encoding_set('8bit') if !is_7bit_clean($part->body);
-        }
-    });
-
     my $from = $email->header('From');
 
     my ($hostname, @args);
@@ -137,6 +127,25 @@ sub MessageToMTA {
     Bugzilla::Hook::process('mailer_before_send', 
                             { email => $email, mailer_args => \@args });
 
+    $email->walk_parts(sub {
+        my ($part) = @_;
+        return if $part->parts > 1; # Top-level
+        my $content_type = $part->content_type || '';
+        if ($content_type !~ /;/) {
+            my $body = $part->body;
+            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($body);
+        }
+    });
+
     if ($method eq "Test") {
         my $filename = bz_locations()->{'datadir'} . '/mailer.testfile';
         open TESTFILE, '>>', $filename;