Fix LP#1031335 by escaping some email headers automatically user/paxed/lp1031335
authorPasi Kallinen <pasi.kallinen@pttk.fi>
Wed, 24 Jul 2013 06:28:13 +0000 (09:28 +0300)
committerPasi Kallinen <pasi.kallinen@pttk.fi>
Wed, 24 Jul 2013 07:12:32 +0000 (10:12 +0300)
Signed-off-by: Pasi Kallinen <pasi.kallinen@pttk.fi>
Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor/SendEmail.pm

index 5cf08c3..9dd76ee 100644 (file)
@@ -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');