From d222dfc7bcfeb7b733b01ab7820f4e2a86ff1069 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 14 Apr 2014 16:33:56 +0200 Subject: [PATCH] Bug 11944: Fix encoding on sending emails This patch fixes 2 places where mails were badly encoded: 1/ At the opac and the intranet, on sending baskets 2/ At the opac and the intranet, on sending shelf/list Test plan: Shelf/List: - Create a list with non-latin characters in the name. - Add some items containing non-latin characters in their content. - Send the list by email Basket/Cart: - Add some items containing non-latin characters in their content to your cart.. - Send the cart by email Signed-off-by: Paola Rossi Signed-off-by: Bernardo Gonzalez Kriegel --- basket/sendbasket.pl | 5 +++-- opac/opac-sendbasket.pl | 5 +++-- opac/opac-sendshelf.pl | 5 +++-- virtualshelves/sendshelf.pl | 8 ++++---- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/basket/sendbasket.pl b/basket/sendbasket.pl index aa38cea..82817bb 100755 --- a/basket/sendbasket.pl +++ b/basket/sendbasket.pl @@ -115,6 +115,7 @@ if ( $email_add ) { if ( $template_res =~ /(.*)/s ) { $mail{subject} = $1; $mail{subject} =~ s|\n?(.*)\n?|$1|; + $mail{subject} = Encode::encode("UTF-8", $mail{subject}); } else { $mail{'subject'} = "no subject"; } @@ -122,7 +123,7 @@ if ( $email_add ) { if ( $template_res =~ /
(.*)/s ) { $email_header = $1; $email_header =~ s|\n?(.*)\n?|$1|; - $email_header = encode_qp($email_header); + $email_header = encode_qp(Encode::encode("UTF-8", $email_header)); } my $email_file = "basket.txt"; @@ -134,7 +135,7 @@ if ( $email_add ) { if ( $template_res =~ /(.*)/s ) { $body = $1; $body =~ s|\n?(.*)\n?|$1|; - $body = encode_qp($body); + $body = encode_qp(Encode::encode("UTF-8", $body)); } my $boundary = "====" . time() . "===="; diff --git a/opac/opac-sendbasket.pl b/opac/opac-sendbasket.pl index c3ff010..928526a 100755 --- a/opac/opac-sendbasket.pl +++ b/opac/opac-sendbasket.pl @@ -131,6 +131,7 @@ if ( $email_add ) { if ( $template_res =~ /(.*)/s ) { $mail{subject} = $1; $mail{subject} =~ s|\n?(.*)\n?|$1|; + $mail{subject} = Encode::encode("UTF-8", $mail{subject}); } else { $mail{'subject'} = "no subject"; } @@ -138,7 +139,7 @@ if ( $email_add ) { if ( $template_res =~ /
(.*)/s ) { $email_header = $1; $email_header =~ s|\n?(.*)\n?|$1|; - $email_header = encode_qp($email_header); + $email_header = encode_qp(Encode::encode("UTF-8", $email_header)); } my $email_file = "basket.txt"; @@ -150,7 +151,7 @@ if ( $email_add ) { if ( $template_res =~ /(.*)/s ) { $body = $1; $body =~ s|\n?(.*)\n?|$1|; - $body = encode_qp($body); + $body = encode_qp(Encode::encode("UTF-8", $body)); } $mail{body} = $body; diff --git a/opac/opac-sendshelf.pl b/opac/opac-sendshelf.pl index d45a33f..a93afee 100755 --- a/opac/opac-sendshelf.pl +++ b/opac/opac-sendshelf.pl @@ -130,12 +130,13 @@ if ( $email ) { $mail{subject} =~ s|\n?(.*)\n?|$1|; } else { $mail{'subject'} = "no subject"; } + $mail{subject} = Encode::encode("UTF-8", $mail{subject}); my $email_header = ""; if ( $template_res =~ /
(.*)/s ) { $email_header = $1; $email_header =~ s|\n?(.*)\n?|$1|; - $email_header = encode_qp($email_header); + $email_header = encode_qp(Encode::encode("UTF-8", $email_header)); } my $email_file = "list.txt"; @@ -147,7 +148,7 @@ if ( $email ) { if ( $template_res =~ /(.*)/s ) { $body = $1; $body =~ s|\n?(.*)\n?|$1|; - $body = encode_qp($body); + $body = encode_qp(Encode::encode("UTF-8", $body)); } my $boundary = "====" . time() . "===="; diff --git a/virtualshelves/sendshelf.pl b/virtualshelves/sendshelf.pl index b00b357..32756dc 100755 --- a/virtualshelves/sendshelf.pl +++ b/virtualshelves/sendshelf.pl @@ -21,7 +21,7 @@ use strict; use warnings; use CGI qw ( -utf8 ); -use Encode qw(encode); +use Encode qw( encode ); use Carp; use Mail::Sendmail; @@ -117,7 +117,7 @@ if ( $email ) { # Analysing information and getting mail properties if ( $template_res =~ /(.*)/s ) { - $mail{subject} = $1; + $mail{'subject'} = Encode::encode("UTF-8", $1); $mail{subject} =~ s|\n?(.*)\n?|$1|; } else { $mail{'subject'} = "no subject"; } @@ -126,7 +126,7 @@ if ( $email ) { if ( $template_res =~ /
(.*)/s ) { $email_header = $1; $email_header =~ s|\n?(.*)\n?|$1|; - $email_header = encode_qp($email_header); + $email_header = encode_qp(Encode::encode("UTF-8", $email_header)); } my $email_file = "list.txt"; @@ -138,7 +138,7 @@ if ( $email ) { if ( $template_res =~ /(.*)/s ) { $body = $1; $body =~ s|\n?(.*)\n?|$1|; - $body = encode_qp($body); + $body = encode_qp(Encode::encode("UTF-8", $body)); } my $boundary = "====" . time() . "===="; -- 1.7.10.4