From 5fc1053c52227c3f2eb56befc6da7b5eb8bc13e7 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 19 Mar 2015 15:18:32 -0300 Subject: [PATCH] Bug 12739: (QA followup) use 'UTF-8' instead of 'utf8' This patch makes Encode::encode be passed the 'UTF-8' encoding instead of the discouraged 'utf8'. Please read: http://wiki.koha-community.org/wiki/Handling_UTF8_in_development Signed-off-by: Tomas Cohen Arazi (cherry picked from commit de7e7d303311a8e306ec5974a0f68c35444a75c2) Signed-off-by: Chris Cormack --- C4/Letters.pm | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index 405dfed8a7..fb21c38989 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -429,9 +429,14 @@ sub SendAlerts { from => $branchdetails->{'branchemail'}, replyto => $branchdetails->{'branchreplyto'}, sender => $branchdetails->{'branchreturnpath'}, - subject => Encode::encode( "utf8", "" . $letter->{title} ), - message => $letter->{'is_html'} ? _wrap_html( Encode::encode( "utf8", $letter->{'content'} ), Encode::encode( "utf8", "" . $letter->{'title'} ) ) : Encode::encode( "utf8", "" . $letter->{'content'} ), - contenttype => $letter->{'is_html'} ? 'text/html; charset="utf-8"' : 'text/plain; charset="utf-8"', + subject => Encode::encode( "UTF-8", "" . $letter->{title} ), + message => $letter->{'is_html'} + ? _wrap_html( Encode::encode( "UTF-8", $letter->{'content'} ), + Encode::encode( "UTF-8", "" . $letter->{'title'} )) + : Encode::encode( "UTF-8", "" . $letter->{'content'} ), + contenttype => $letter->{'is_html'} + ? 'text/html; charset="utf-8"' + : 'text/plain; charset="utf-8"', } ); sendmail(%mail) or carp $Mail::Sendmail::error; @@ -515,9 +520,14 @@ sub SendAlerts { To => join( ',', @email), Cc => join( ',', @cc), From => $userenv->{emailaddress}, - Subject => Encode::encode( "utf8", "" . $letter->{title} ), - Message => $letter->{'is_html'} ? _wrap_html( Encode::encode( "utf8", $letter->{'content'} ), Encode::encode( "utf8", "" . $letter->{'title'} ) ) : Encode::encode( "utf8", "" . $letter->{'content'} ), - 'Content-Type' => $letter->{'is_html'} ? 'text/html; charset="utf-8"' : 'text/plain; charset="utf-8"', + Subject => Encode::encode( "UTF-8", "" . $letter->{title} ), + Message => $letter->{'is_html'} + ? _wrap_html( Encode::encode( "UTF-8", $letter->{'content'} ), + Encode::encode( "UTF-8", "" . $letter->{'title'} )) + : Encode::encode( "UTF-8", "" . $letter->{'content'} ), + 'Content-Type' => $letter->{'is_html'} + ? 'text/html; charset="utf-8"' + : 'text/plain; charset="utf-8"', ); $mail{'Reply-to'} = C4::Context->preference('ReplytoDefault') @@ -564,9 +574,14 @@ sub SendAlerts { from => $branchdetails->{'branchemail'}, replyto => $branchdetails->{'branchreplyto'}, sender => $branchdetails->{'branchreturnpath'}, - subject => Encode::encode( "utf8", "" . $letter->{'title'} ), - message => $letter->{'is_html'} ? _wrap_html( Encode::encode( "utf8", $letter->{'content'} ), Encode::encode( "utf8", "" . $letter->{'title'} ) ) : Encode::encode( "utf8", "" . $letter->{'content'} ), - contenttype => $letter->{'is_html'} ? 'text/html; charset="utf-8"' : 'text/plain; charset="utf-8"', + subject => Encode::encode( "UTF-8", "" . $letter->{'title'} ), + message => $letter->{'is_html'} + ? _wrap_html( Encode::encode( "UTF-8", $letter->{'content'} ), + Encode::encode( "UTF-8", "" . $letter->{'title'} ) ) + : Encode::encode( "UTF-8", "" . $letter->{'content'} ), + contenttype => $letter->{'is_html'} + ? 'text/html; charset="utf-8"' + : 'text/plain; charset="utf-8"', } ); sendmail(%mail) or carp $Mail::Sendmail::error; @@ -1132,8 +1147,8 @@ sub _send_message_by_email { my $utf8 = decode('MIME-Header', $message->{'subject'} ); $message->{subject}= encode('MIME-Header', $utf8); - my $subject = encode('utf8', $message->{'subject'}); - my $content = encode('utf8', $message->{'content'}); + my $subject = encode('UTF-8', $message->{'subject'}); + my $content = encode('UTF-8', $message->{'content'}); my $content_type = $message->{'content_type'} || 'text/plain; charset="UTF-8"'; my $is_html = $content_type =~ m/html/io; my $branch_email = undef; -- 2.39.5