LP#1801163: (follow-up) deal with header fields that contain Unicode strings
authorGalen Charlton <gmc@equinoxinitiative.org>
Fri, 3 Jan 2020 22:55:10 +0000 (17:55 -0500)
committerJason Boyer <JBoyer@eoli.info>
Thu, 23 Jan 2020 12:30:14 +0000 (07:30 -0500)
Since Email::MIME->header_str_set() expects Unicode strings, not octets,
use decode_utf8() on the header values to

To test
-------
[1] Update the biblio.format.record_entry.print A/T event definition
    to include non-ASCII characters in the subject and from headers.
[2] Upon applying the patch series, verifying that the strings provided
    in step 1 are not mangled when the email is sent.

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Jason Boyer <JBoyer@eoli.info>

Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor/SendEmail.pm

index 675ab69..8f7a321 100644 (file)
@@ -62,13 +62,13 @@ sub handler {
     # properly, we make sure there is only 1 each.
     for my $hfield (qw/From To Bcc Cc Reply-To Sender/) {
         my @headers = $email->header($hfield);
-        $email->header_str_set($hfield => join(',', @headers)) if ($headers[0]);
+        $email->header_str_set($hfield => decode_utf8(join(',', @headers))) if ($headers[0]);
     }
 
     # Handle the Subject field.  Again, the standard says there can be
     # only one.
     my @headers = $email->header('Subject');
-    $email->header_str_set('Subject' => $headers[0]) if ($headers[0]);
+    $email->header_str_set('Subject' => decode_utf8($headers[0])) if ($headers[0]);
 
     $email->header_set('MIME-Version' => '1.0');
     $email->header_set('Content-Type' => "text/plain; charset=UTF-8");