aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/lib/action_mailer/vendor
diff options
context:
space:
mode:
Diffstat (limited to 'actionmailer/lib/action_mailer/vendor')
-rw-r--r--actionmailer/lib/action_mailer/vendor/tmail/attachments.rb11
-rw-r--r--actionmailer/lib/action_mailer/vendor/tmail/quoting.rb12
2 files changed, 12 insertions, 11 deletions
diff --git a/actionmailer/lib/action_mailer/vendor/tmail/attachments.rb b/actionmailer/lib/action_mailer/vendor/tmail/attachments.rb
index 52455e5d2d..e78d2f91d2 100644
--- a/actionmailer/lib/action_mailer/vendor/tmail/attachments.rb
+++ b/actionmailer/lib/action_mailer/vendor/tmail/attachments.rb
@@ -14,18 +14,19 @@ module TMail
if multipart?
parts.collect { |part|
if part.header["content-type"].main_type != "text"
- content = part.body.unpack("m")[0]
- content = part.body if content.blank?
- file_name = part.header["content-type"].params["name"]
+ content = part.body # unquoted automatically by TMail#body
+ file_name = part.header["content-type"].params["name"] ||
+ part.header["content-disposition"].params["filename"]
next if file_name.blank? || content.blank?
attachment = Attachment.new(content)
- attachment.original_filename = file_name.strip.dup
+ attachment.original_filename = file_name.strip
+ attachment.content_type = part.content_type
attachment
end
}.compact
end
end
end
-end \ No newline at end of file
+end
diff --git a/actionmailer/lib/action_mailer/vendor/tmail/quoting.rb b/actionmailer/lib/action_mailer/vendor/tmail/quoting.rb
index a31638100b..0c2653a6e0 100644
--- a/actionmailer/lib/action_mailer/vendor/tmail/quoting.rb
+++ b/actionmailer/lib/action_mailer/vendor/tmail/quoting.rb
@@ -1,5 +1,3 @@
-require 'base64'
-
module TMail
class Mail
def subject(to_charset = 'utf-8')
@@ -29,9 +27,10 @@ module TMail
if multipart?
parts.collect { |part|
- part.header["content-type"].main_type == "text" ?
+ header = part.header["content-type"]
+ header && header.main_type == "text" ?
part.unquoted_body(to_charset) :
- attachment_presenter.call(part.header["content-type"].params["name"])
+ (header ? attachment_presenter.call(header.params["name"]) : "")
}.join
else
unquoted_body(to_charset)
@@ -65,13 +64,14 @@ module TMail
end
def unquote_base64_and_convert_to(text, to, from)
- convert_to(Base64.decode64(text), to, from)
+ convert_to(Base64.decode(text).first, to, from)
end
begin
require 'iconv'
def convert_to(text, to, from)
- text ? Iconv.iconv(to, from || "ISO-8859-1", text).first : ""
+ return text unless to && from
+ text ? Iconv.iconv(to, from, text).first : ""
end
rescue LoadError
# Not providing quoting support