aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/incoming_message.rb4
-rw-r--r--lib/mail_handler/backends/mail_backend.rb3
-rw-r--r--lib/mail_handler/backends/tmail_backend.rb4
3 files changed, 6 insertions, 5 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index 4ae0b8520..3f45a425d 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -212,12 +212,12 @@ class IncomingMessage < ActiveRecord::Base
if part.content_type == 'message/rfc822'
# An email attached as text
# e.g. http://www.whatdotheyknow.com/request/64/response/102
- part.rfc822_attachment = TMail::Mail.parse(part.body)
+ part.rfc822_attachment = MailHandler.mail_from_raw_email(part.body, decode=false)
elsif part.content_type == 'application/vnd.ms-outlook' || part_filename && AlaveteliFileTypes.filename_to_mimetype(part_filename) == 'application/vnd.ms-outlook'
# An email attached as an Outlook file
# e.g. http://www.whatdotheyknow.com/request/chinese_names_for_british_politi
msg = Mapi::Msg.open(StringIO.new(part.body))
- part.rfc822_attachment = TMail::Mail.parse(msg.to_mime.to_s)
+ part.rfc822_attachment = MailHandler.mail_from_raw_email(msg.to_mime.to_s, decode=false)
elsif part.content_type == 'application/ms-tnef'
# A set of attachments in a TNEF file
part.rfc822_attachment = TNEF.as_tmail(part.body)
diff --git a/lib/mail_handler/backends/mail_backend.rb b/lib/mail_handler/backends/mail_backend.rb
index f7dbb7624..6a5fff13f 100644
--- a/lib/mail_handler/backends/mail_backend.rb
+++ b/lib/mail_handler/backends/mail_backend.rb
@@ -8,7 +8,8 @@ module MailHandler
'Mail'
end
- def mail_from_raw_email(data)
+ # Note that the decode flag is not yet used
+ def mail_from_raw_email(data, decode=true)
Mail.new(data)
end
diff --git a/lib/mail_handler/backends/tmail_backend.rb b/lib/mail_handler/backends/tmail_backend.rb
index ff00d92df..2f59b1161 100644
--- a/lib/mail_handler/backends/tmail_backend.rb
+++ b/lib/mail_handler/backends/tmail_backend.rb
@@ -17,13 +17,13 @@ module MailHandler
# Turn raw data into a structured TMail::Mail object
# Documentation at http://i.loveruby.net/en/projects/tmail/doc/
- def mail_from_raw_email(data)
+ def mail_from_raw_email(data, decode=true)
# Hack round bug in TMail's MIME decoding.
# Report of TMail bug:
# http://rubyforge.org/tracker/index.php?func=detail&aid=21810&group_id=4512&atid=17370
copy_of_raw_data = data.gsub(/; boundary=\s+"/im,'; boundary="')
mail = TMail::Mail.parse(copy_of_raw_data)
- mail.base64_decode
+ mail.base64_decode if decode
mail
end