Commit 652ee918 authored by Frédéric Buclin's avatar Frédéric Buclin

Bug 1246228 - Email addresses must not be encoded

r/a=dkl
parent aa5f64e1
...@@ -13,9 +13,6 @@ use warnings; ...@@ -13,9 +13,6 @@ use warnings;
use parent qw(Email::MIME); use parent qw(Email::MIME);
use Encode qw(encode);
use Encode::MIME::Header;
sub new { sub new {
my ($class, $msg) = @_; my ($class, $msg) = @_;
state $use_utf8 = Bugzilla->params->{'utf8'}; state $use_utf8 = Bugzilla->params->{'utf8'};
...@@ -79,20 +76,12 @@ sub as_string { ...@@ -79,20 +76,12 @@ sub as_string {
# MIME-Version must be set otherwise some mailsystems ignore the charset # MIME-Version must be set otherwise some mailsystems ignore the charset
$self->header_set('MIME-Version', '1.0') if !$self->header('MIME-Version'); $self->header_set('MIME-Version', '1.0') if !$self->header('MIME-Version');
# Encode the headers correctly in quoted-printable # Encode the headers correctly.
foreach my $header ($self->header_names) { foreach my $header ($self->header_names) {
my @values = $self->header($header); my @values = $self->header($header);
# We don't recode headers that happen multiple times. map { utf8::decode($_) if defined($_) && !utf8::is_utf8($_) } @values;
next if scalar(@values) > 1;
if (my $value = $values[0]) {
utf8::decode($value) unless $use_utf8 && utf8::is_utf8($value);
# avoid excessive line wrapping done by Encode.
local $Encode::Encoding{'MIME-Q'}->{'bpl'} = 998;
my $encoded = encode('MIME-Q', $value); $self->header_str_set($header, @values);
$self->header_set($header, $encoded);
}
} }
# Ensure the character-set and encoding is set correctly on single part # Ensure the character-set and encoding is set correctly on single part
......
...@@ -26,6 +26,7 @@ use Bugzilla::Attachment::PatchReader; ...@@ -26,6 +26,7 @@ use Bugzilla::Attachment::PatchReader;
use Bugzilla::Token; use Bugzilla::Token;
use Encode qw(encode find_encoding); 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 # For most scripts we don't make $cgi and $template global variables. But
# when preparing Bugzilla for mod_perl, this script used these # when preparing Bugzilla for mod_perl, this script used these
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment