aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mail_handler/backends/mail_backend.rb
diff options
context:
space:
mode:
authorMark Longair <mhl@pobox.com>2013-05-15 14:52:24 +0100
committerMark Longair <mhl@pobox.com>2013-05-16 09:06:27 +0100
commit2d5ddc2d37837cb9ee80931b09dff04cc1120bda (patch)
treecf54cab06dacf7e804d10f8b293222e4b1f14ce2 /lib/mail_handler/backends/mail_backend.rb
parent95cf55aad1f0985d28c28beb61e122dc7465b039 (diff)
Make efforts to ensure that we're usually dealing with UTF-8 strings
One of these changes is to make sure that the Mail backend, like the TMail backend it replaces, will return text parts encoded in UTF-8 if possible. The other change is to ensure that when text attachments are reloaded from disk, we attempt to convert them to UTF-8.
Diffstat (limited to 'lib/mail_handler/backends/mail_backend.rb')
-rw-r--r--lib/mail_handler/backends/mail_backend.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/mail_handler/backends/mail_backend.rb b/lib/mail_handler/backends/mail_backend.rb
index bd3a91569..f0dfc843c 100644
--- a/lib/mail_handler/backends/mail_backend.rb
+++ b/lib/mail_handler/backends/mail_backend.rb
@@ -38,7 +38,11 @@ module MailHandler
# Get the body of a mail part
def get_part_body(part)
- part.body.decoded
+ decoded = part.body.decoded
+ if part.content_type =~ /^text\//
+ decoded = convert_string_to_utf8_or_binary decoded, part.charset
+ end
+ decoded
end
# Return the first from field if any