aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mail_handler/backends/mail_backend.rb
diff options
context:
space:
mode:
authorMark Longair <mhl@pobox.com>2013-05-02 15:34:08 +0100
committerMark Longair <mhl@pobox.com>2013-05-16 09:06:27 +0100
commit2805cc72a21089ea9725352b1d4d39d7d929a7a0 (patch)
tree91548ee398fa91532afcaa1dd1536b9516871740 /lib/mail_handler/backends/mail_backend.rb
parentec414d4dcb0c027be6c59ce873127dc10037dc50 (diff)
Ignore common TNEF attachment parsing errors
This also introduces a custom error class so that we don't accidentally catch other problems. Fixes #920
Diffstat (limited to 'lib/mail_handler/backends/mail_backend.rb')
-rw-r--r--lib/mail_handler/backends/mail_backend.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/mail_handler/backends/mail_backend.rb b/lib/mail_handler/backends/mail_backend.rb
index f7893a60d..bd3a91569 100644
--- a/lib/mail_handler/backends/mail_backend.rb
+++ b/lib/mail_handler/backends/mail_backend.rb
@@ -141,9 +141,14 @@ module MailHandler
end
elsif get_content_type(part) == 'application/ms-tnef'
# A set of attachments in a TNEF file
- part.rfc822_attachment = mail_from_tnef(part.body.decoded)
- if part.rfc822_attachment.nil?
- # Attached mail didn't parse, so treat as binary
+ begin
+ part.rfc822_attachment = mail_from_tnef(part.body.decoded)
+ if part.rfc822_attachment.nil?
+ # Attached mail didn't parse, so treat as binary
+ part.content_type = 'application/octet-stream'
+ end
+ rescue TNEFParsingError
+ part.rfc822_attachment = nil
part.content_type = 'application/octet-stream'
end
end