From 76ca4532ee6c8d1ff35d45899aec0ae2ec996b4e Mon Sep 17 00:00:00 2001
From: dbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Tue, 1 Mar 2011 04:16:07 +0000
Subject: [PATCH] Add a TT helper to encode email headers in UTF-8

This can and should be used to encode any headers (To, From, Subject, etc)
in an email that might include text outside of the ASCII 7-bit range. Names
of people or libraries, for example, that might otherwise come out garbled.


git-svn-id: svn://svn.open-ils.org/ILS/trunk@19546 dcc99617-32d9-48b4-a31d-7c20da2025e4
---
 Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor.pm | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor.pm
index 4be542b0d6..4251519630 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor.pm
@@ -1,5 +1,6 @@
 package OpenILS::Application::Trigger::Reactor;
 use strict; use warnings;
+use Encode qw/ encode /;
 use Template;
 use DateTime;
 use DateTime::Format::ISO8601;
@@ -49,6 +50,13 @@ my $_TT_helpers = {
         return $str;
     },
 
+    # encode email headers in UTF-8, per RFC2231
+    escape_email_header => sub {
+        my $str = shift;
+        $str = encode("MIME-Header", $str);
+        return $str;
+    },
+
     # strip non-ASCII characters after splitting base characters and diacritics
     # least common denominator for EDIFACT messages using the UNOB character set
     force_jedi_unob => sub {
-- 
2.11.0