From: Moritz Bunkus Date: Wed, 31 Oct 2012 15:57:53 +0000 (+0100) Subject: Bei Verwendung von SMTP nicht doppelt nach UTF-8 encoden X-Git-Tag: release-3.0.0beta1~62 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=11e0660ffd9f7c92b96fd3d47d190399f03a2a8a;p=kivitendo-erp.git Bei Verwendung von SMTP nicht doppelt nach UTF-8 encoden Die SMTP-Module erwarten, dass die Strings im Perl-internen Encoding vorliegen. Das tun sie in Mailer.pm auch schon, allerdings wurden sie dort bisher nach UTF-8 encodiert, weil der Sendmail-Treiber es so brauchte. Also die richtige Variante: - Mailer.pm verändert das Encoding nicht - Mailer/Sendmail.pm setzt :utf8 als I/O-Layer auf der Pipe zum externen Prozess Behebt #2035. --- diff --git a/SL/Mailer.pm b/SL/Mailer.pm index cdfe9a401..0880eecc7 100644 --- a/SL/Mailer.pm +++ b/SL/Mailer.pm @@ -124,7 +124,7 @@ sub send { $num_sent++; my $boundary = time() . "-$$-${num_sent}"; $boundary = "kivitendo-$self->{version}-$boundary"; - my $domain = $self->recode($self->{from}); + my $domain = $self->{from}; $domain =~ s/(.*?\@|>)//g; my $msgid = "$boundary\@$domain"; @@ -142,15 +142,12 @@ sub send { foreach my $item (qw(to cc bcc)) { next unless ($self->{$item}); - $self->{$item} = $self->recode($self->{$item}); $self->{$item} =~ s/\</{$item} =~ s/\$<\$/{$item} =~ s/\>/>/g; $self->{$item} =~ s/\$>\$/>/g; } - $self->{from} = $self->recode($self->{from}); - my %addresses; my $headers = ''; foreach my $item (qw(from to cc bcc)) { @@ -173,7 +170,7 @@ sub send { } } - $headers .= sprintf("Subject: %s\n", $self->mime_quote_text($self->recode($self->{subject}), 60)); + $headers .= sprintf("Subject: %s\n", $self->mime_quote_text($self->{subject}, 60)); $driver->start_mail(from => $self->{from}, to => [ map { @{ $addresses{$_} } } qw(to cc bcc) ]); @@ -188,7 +185,7 @@ MIME-Version: 1.0 $driver->print(qq|--${boundary} Content-Type: $self->{contenttype}; charset="$self->{charset}" -| . $self->recode($self->{message}) . qq| +$self->{message} |); } @@ -236,7 +233,7 @@ Content-Disposition: attachment; filename="$filename"\n\n|); } else { $driver->print(qq|Content-Type: $self->{contenttype}; charset="$self->{charset}" -| . $self->recode($self->{message}) . qq| +$self->{message} |); } @@ -275,11 +272,4 @@ sub encode_base64 ($;$) { return $res; } -sub recode { - my $self = shift; - my $text = shift; - - return $::locale->is_utf8 ? Encode::encode('utf-8-strict', $text) : $text; -} - 1; diff --git a/SL/Mailer/Sendmail.pm b/SL/Mailer/Sendmail.pm index 6b24ecdb5..c4ab66252 100644 --- a/SL/Mailer/Sendmail.pm +++ b/SL/Mailer/Sendmail.pm @@ -26,6 +26,7 @@ sub init { $sendmail = $template->parse_block($sendmail); $self->{sendmail} = IO::File->new("|$sendmail") || die "sendmail($sendmail): $!"; + $self->{sendmail}->binmode(':utf8') if $::locale->is_utf8; } sub start_mail {