[bugzilla-gnome-org-upstream/4.4] Bug 1246228 - Email addresses must not be encoded r/a=dkl



commit f630337aeeedf10c05509167df71358569c4b3d8
Author: Frédéric Buclin <LpSolit gmail com>
Date:   Fri May 13 20:30:42 2016 +0200

    Bug 1246228 - Email addresses must not be encoded
    r/a=dkl

 Bugzilla/Mailer.pm |   18 +++---------------
 attachment.cgi     |    1 +
 2 files changed, 4 insertions(+), 15 deletions(-)
---
diff --git a/Bugzilla/Mailer.pm b/Bugzilla/Mailer.pm
index 6464015..1149eb0 100644
--- a/Bugzilla/Mailer.pm
+++ b/Bugzilla/Mailer.pm
@@ -19,8 +19,6 @@ use Bugzilla::Util;
 
 use Date::Format qw(time2str);
 
-use Encode qw(encode);
-use Encode::MIME::Header;
 use Email::Address;
 use Email::MIME;
 # Return::Value 1.666002 pollutes the error log with warnings about this
@@ -71,22 +69,12 @@ sub MessageToMTA {
     # MIME-Version must be set otherwise some mailsystems ignore the charset
     $email->header_set('MIME-Version', '1.0') if !$email->header('MIME-Version');
 
-    # Encode the headers correctly in quoted-printable
+    # Encode the headers correctly.
     foreach my $header ($email->header_names) {
         my @values = $email->header($header);
-        # We don't recode headers that happen multiple times.
-        next if scalar(@values) > 1;
-        if (my $value = $values[0]) {
-            if (Bugzilla->params->{'utf8'} && !utf8::is_utf8($value)) {
-                utf8::decode($value);
-            }
-
-            # avoid excessive line wrapping done by Encode.
-            local $Encode::Encoding{'MIME-Q'}->{'bpl'} = 998;
+        map { utf8::decode($_) if defined($_) && !utf8::is_utf8($_) } @values;
 
-            my $encoded = encode('MIME-Q', $value);
-            $email->header_set($header, $encoded);
-        }
+        $email->header_str_set($header, @values);
     }
 
     my $from = $email->header('From');
diff --git a/attachment.cgi b/attachment.cgi
index e003e1f..319e46f 100755
--- a/attachment.cgi
+++ b/attachment.cgi
@@ -31,6 +31,7 @@ use Bugzilla::Token;
 use Bugzilla::Keyword;
 
 use Encode qw(encode find_encoding);
+use Encode::MIME::Header; # Required to alter Encode::Encoding{'MIME-Q'}.
 
 # For most scripts we don't make $cgi and $template global variables. But
 # when preparing Bugzilla for mod_perl, this script used these


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]