aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-05-10 13:40:26 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-05-10 13:40:26 +0000
commit9c9286710268ff124ffe68727030dbe401bbc3c2 (patch)
tree8816e11fe7396c03412b5ffac79ad6a6d65c230a /actionmailer/lib
parent8983a097522c08f4173abad5c1715268f31e994a (diff)
downloadrails-9c9286710268ff124ffe68727030dbe401bbc3c2.tar.gz
rails-9c9286710268ff124ffe68727030dbe401bbc3c2.tar.bz2
rails-9c9286710268ff124ffe68727030dbe401bbc3c2.zip
Fix attachments and content-type problems #1276 [Jamis Buck] Fix to only perform the charset conversion if a 'from' and a 'to' charset are given (make no assumptions about what the charset was) #1276 [Jamis Buck]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1300 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionmailer/lib')
-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