diff options
author | Mark Longair <mhl@pobox.com> | 2013-05-28 14:39:09 +0100 |
---|---|---|
committer | Mark Longair <mhl@pobox.com> | 2013-05-28 14:39:09 +0100 |
commit | c248356a8e8a13513827381977b24f7406f96a8c (patch) | |
tree | a0b2210c5956d0da8ea534fe8b772cd776087460 /lib/mail_handler/mail_handler.rb | |
parent | ed03c3ef55fd61b9be3578ee0c93767d2c218b53 (diff) | |
parent | 011e55bd4acf4f3c9de91c5ed4c646e855f19c24 (diff) |
Merge branch 'tmail-to-mail-tests' into rails-3-develop
This merge brings in a number of tests and fixes for the handling
of mail under Mail / Rails 3 instead of TMail / Rails 2.
Conflicts:
config/initializers/alaveteli.rb
Diffstat (limited to 'lib/mail_handler/mail_handler.rb')
-rw-r--r-- | lib/mail_handler/mail_handler.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/mail_handler/mail_handler.rb b/lib/mail_handler/mail_handler.rb index 22ba26b97..9c955cccd 100644 --- a/lib/mail_handler/mail_handler.rb +++ b/lib/mail_handler/mail_handler.rb @@ -8,20 +8,23 @@ module MailHandler require 'backends/mail_backend' include Backends::MailBackend + class TNEFParsingError < StandardError + end + # Returns a set of attachments from the given TNEF contents # The TNEF contents also contains the message body, but in general this is the # same as the message body in the message proper. def tnef_attachments(content) attachments = [] Dir.mktmpdir do |dir| - IO.popen("#{`which tnef`.chomp} -K -C #{dir}", "wb") do |f| + IO.popen("tnef -K -C #{dir} 2> /dev/null", "wb") do |f| f.write(content) f.close if $?.signaled? raise IOError, "tnef exited with signal #{$?.termsig}" end if $?.exited? && $?.exitstatus != 0 - raise IOError, "tnef exited with status #{$?.exitstatus}" + raise TNEFParsingError, "tnef exited with status #{$?.exitstatus}" end end found = 0 @@ -34,7 +37,7 @@ module MailHandler end end if found == 0 - raise IOError, "tnef produced no attachments" + raise TNEFParsingError, "tnef produced no attachments" end end attachments |