From a8d5a7ff6ad440b6a973255f2ad5135946c75916 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 24 Jul 2013 09:28:13 +0300 Subject: [PATCH] Fix LP#1031335 by escaping some email headers automatically Signed-off-by: Pasi Kallinen Signed-off-by: Dan Scott Signed-off-by: Dan Wells --- .../lib/OpenILS/Application/Trigger/Reactor/SendEmail.pm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor/SendEmail.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor/SendEmail.pm index 5cf08c3b70..9dd76ee454 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor/SendEmail.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor/SendEmail.pm @@ -29,6 +29,9 @@ Email is encoded in UTF-8 and the corresponding MIME-Version, Content-Type, and Content-Transfer-Encoding headers are set to help mail user agents decode the content. +The From, To, Subject, Bcc, Cc, Reply-To and Sender -fields are +automatically MIME-encoded. + No default template is assumed, and all information other than the default_sender that the system provides is expected to be gathered by the Event Definition through either Environment or Parameter definitions. @@ -54,6 +57,12 @@ sub handler { my $err; my $email = Email::Simple->new($text); + + for my $hfield (qw/From To Subject Bcc Cc Reply-To Sender/) { + my @headers = $email->header($hfield); + $email->header_set($hfield => map { encode("MIME-Header", $_) } @headers) if ($headers[0]); + } + $email->header_set('MIME-Version' => '1.0'); $email->header_set('Content-Type' => "text/plain; charset=UTF-8"); $email->header_set('Content-Transfer-Encoding' => '8bit'); -- 2.11.0