From 9afcd220439a95c611dbe9300f586f44e83db59f Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 14 Nov 2013 14:05:53 +0100 Subject: [PATCH] Bug 11248: fix encoding issue on emailing a list (OPAC) Test plan: - send a list via email with the english version. - translate templates and retry with another language. Signed-off-by: Katrin Fischer Works nicely. Links to the OPAC are correct. Signed-off-by: Kyle M Hall Signed-off-by: Galen Charlton (cherry picked from commit 394ece2e1012aebdc5543f739c5438f91c66d477) Signed-off-by: Fridolin Somers Signed-off-by: Kyle M Hall (cherry picked from commit 51d7f2da3a59a06bd0089cad5f34077c1811ca8a) --- opac/opac-sendshelf.pl | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/opac/opac-sendshelf.pl b/opac/opac-sendshelf.pl index 80b54e2a6c..3f9b719987 100755 --- a/opac/opac-sendshelf.pl +++ b/opac/opac-sendshelf.pl @@ -21,7 +21,7 @@ use strict; use warnings; use CGI; -use Encode; +use Encode qw(decode encode); use Carp; use Mail::Sendmail; @@ -122,19 +122,32 @@ if ( $email ) { # Getting template result my $template_res = $template2->output(); + my $body; # Analysing information and getting mail properties - $mail{'subject'} = $template_res =~ /\n(.*)\n?/s - ? $1 : "no subject"; + if ( $template_res =~ /(.*)/s ) { + $mail{subject} = $1; + $mail{subject} =~ s|\n?(.*)\n?|$1|; + } + else { $mail{'subject'} = "no subject"; } - my ($email_header) = $template_res =~ /
\n(.*)\n?/s; + my $email_header = ""; + if ( $template_res =~ /
(.*)/s ) { + $email_header = $1; + $email_header =~ s|\n?(.*)\n?|$1|; + } - my $email_file = $template_res =~ /\n(.*)\n?/s - ? $1 - : "list.txt"; + my $email_file = "list.txt"; + if ( $template_res =~ /(.*)/s ) { + $email_file = $1; + $email_file =~ s|\n?(.*)\n?|$1|; + } - my ($body) = $template_res =~ /\n(.*)\n?/s; - $body = encode_qp($body); + if ( $template_res =~ /(.*)/s ) { + $body = $1; + $body =~ s|\n?(.*)\n?|$1|; + $body = encode("UTF-8", encode_qp($body)); + } my $boundary = "====" . time() . "===="; -- 2.39.5