From 3dcfeace1e6fc0b9ac67a96c8d8cabb58feff12a Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 14 Nov 2013 14:05:53 +0100 Subject: [PATCH] [SIGNED OFF] Bug 11248: Encoding issue on sending a list (OPAC) See bug 10605 for more details. 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. --- 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 80b54e2..3f9b719 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() . "===="; -- 1.8.3.2