diff options
Diffstat (limited to 'lib/mail_handler')
-rw-r--r-- | lib/mail_handler/backends/mail_backend.rb | 10 | ||||
-rw-r--r-- | lib/mail_handler/backends/mail_extensions.rb | 9 | ||||
-rw-r--r-- | lib/mail_handler/mail_handler.rb | 3 |
3 files changed, 15 insertions, 7 deletions
diff --git a/lib/mail_handler/backends/mail_backend.rb b/lib/mail_handler/backends/mail_backend.rb index 974873b30..34fbc91ab 100644 --- a/lib/mail_handler/backends/mail_backend.rb +++ b/lib/mail_handler/backends/mail_backend.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- require 'mail' require 'mapi/msg' require 'mapi/convert' @@ -35,7 +36,7 @@ module MailHandler module Backends module MailBackend - def backend() + def backend 'Mail' end @@ -64,7 +65,12 @@ module MailHandler # Return a copy of the file name for the mail part def get_part_file_name(part) part_file_name = part.filename - part_file_name.nil? ? nil : part_file_name.dup + part_file_name = part_file_name.nil? ? nil : part_file_name.dup + if part_file_name + part_file_name = CGI.unescape(part_file_name) + part_file_name = convert_string_to_utf8(part_file_name, part.charset) + end + part_file_name end # Get the body of a mail part diff --git a/lib/mail_handler/backends/mail_extensions.rb b/lib/mail_handler/backends/mail_extensions.rb index f778cbc14..b39e54d08 100644 --- a/lib/mail_handler/backends/mail_extensions.rb +++ b/lib/mail_handler/backends/mail_extensions.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- require 'mail/message' require 'mail/part' require 'mail/fields/common/parameter_hash' @@ -37,7 +38,7 @@ module Mail # Can be removed when we no longer support Ruby 1.8 class Ruby18 - def Ruby18.b_value_decode(str) + def self.b_value_decode(str) match = str.match(/\=\?(.+)?\?[Bb]\?(.+)?\?\=/m) if match encoding = match[1] @@ -55,7 +56,7 @@ module Mail str end - def Ruby18.q_value_decode(str) + def self.q_value_decode(str) match = str.match(/\=\?(.+)?\?[Qq]\?(.+)?\?\=/m) if match encoding = match[1] @@ -75,7 +76,7 @@ module Mail private - def Ruby18.fix_encoding(encoding) + def self.fix_encoding(encoding) case encoding.upcase when 'UTF8' 'UTF-8' @@ -86,7 +87,7 @@ module Mail end class Ruby19 - def Ruby19.b_value_decode(str) + def self.b_value_decode(str) match = str.match(/\=\?(.+)?\?[Bb]\?(.+)?\?\=/m) if match charset = match[1] diff --git a/lib/mail_handler/mail_handler.rb b/lib/mail_handler/mail_handler.rb index 33d939e22..313869d16 100644 --- a/lib/mail_handler/mail_handler.rb +++ b/lib/mail_handler/mail_handler.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # Handles the parsing of email require 'tmpdir' @@ -133,7 +134,7 @@ module MailHandler begin zip_file = Zip::ZipFile.open(tempfile.path) text += get_attachment_text_from_zip_file(zip_file) - zip_file.close() + zip_file.close rescue $stderr.puts("Error processing zip file: #{$!.inspect}") end |