diff options
author | Louise Crow <louise.crow@gmail.com> | 2013-06-03 10:50:17 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2013-06-03 10:50:17 +0100 |
commit | 050b25bd70909913b7e42d53cb69c31b1396cc46 (patch) | |
tree | ac2f2b587ffa3504c5cf5164b36f5f436c0582f4 /lib/mail_handler/mail_handler.rb | |
parent | 4db18138584b6394286bbe374f22e6609ab79136 (diff) | |
parent | e30a8623a1706d3bad4476198085547d8f47cc88 (diff) |
Merge branch 'release/0.11' into wdtk
Diffstat (limited to 'lib/mail_handler/mail_handler.rb')
-rw-r--r-- | lib/mail_handler/mail_handler.rb | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/lib/mail_handler/mail_handler.rb b/lib/mail_handler/mail_handler.rb index cd5abfab7..9c955cccd 100644 --- a/lib/mail_handler/mail_handler.rb +++ b/lib/mail_handler/mail_handler.rb @@ -3,16 +3,12 @@ require 'tmpdir' module MailHandler - if RUBY_VERSION.to_f >= 1.9 - require 'mail' - require 'backends/mail_extensions' - require 'backends/mail_backend' - include Backends::MailBackend - else - require 'action_mailer' - require 'backends/tmail_extensions' - require 'backends/tmail_backend' - include Backends::TmailBackend + require 'mail' + require 'backends/mail_extensions' + require 'backends/mail_backend' + include Backends::MailBackend + + class TNEFParsingError < StandardError end # Returns a set of attachments from the given TNEF contents @@ -21,14 +17,14 @@ module MailHandler 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 @@ -41,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 |