diff options
author | Jamis Buck <jamis@37signals.com> | 2005-06-03 09:05:06 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2005-06-03 09:05:06 +0000 |
commit | 887497b0bb8725018837ddce162363c5f0e3f0b9 (patch) | |
tree | 7e06300ef938d98b0139932ac140d320c899dac4 /actionmailer/lib/action_mailer | |
parent | 32c0e895bfa521acdc5c7031a2285a3b8dd53130 (diff) | |
download | rails-887497b0bb8725018837ddce162363c5f0e3f0b9.tar.gz rails-887497b0bb8725018837ddce162363c5f0e3f0b9.tar.bz2 rails-887497b0bb8725018837ddce162363c5f0e3f0b9.zip |
Don't apply a charset to attachments. Wrap base64-encoded lines.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1381 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionmailer/lib/action_mailer')
-rw-r--r-- | actionmailer/lib/action_mailer/part.rb | 48 |
1 files changed, 4 insertions, 44 deletions
diff --git a/actionmailer/lib/action_mailer/part.rb b/actionmailer/lib/action_mailer/part.rb index e26742816a..9f95df0a16 100644 --- a/actionmailer/lib/action_mailer/part.rb +++ b/actionmailer/lib/action_mailer/part.rb @@ -21,56 +21,16 @@ module ActionMailer def to_mail(defaults) part = TMail::Mail.new part.set_content_type(content_type, nil, - "charset" => charset || defaults.charset, "name" => filename) + "charset" => (content_disposition == "attachment" ? + nil : (charset || defaults.charset)), + "name" => filename) part.set_content_disposition(content_disposition, "filename" => filename) part.content_transfer_encoding = transfer_encoding || "quoted-printable" case (transfer_encoding || "").downcase when "base64" then - part.body = TMail::Base64.encode(body) - when "quoted-printable" - part.body = [body].pack("M*") - else - part.body = body - end - - part - end - end - -end -require 'action_mailer/adv_attr_accessor' - -module ActionMailer - - class Part #:nodoc: - include ActionMailer::AdvAttrAccessor - - adv_attr_accessor :content_type, :content_disposition, :charset, :body - adv_attr_accessor :filename, :transfer_encoding, :headers - - def initialize(params) - @content_type = params[:content_type] || "text/plain" - @content_disposition = params[:disposition] || "inline" - @charset = params[:charset] - @body = params[:body] - @filename = params[:filename] - @transfer_encoding = params[:transfer_encoding] || "quoted-printable" - @headers = params[:headers] || {} - end - - def to_mail(defaults) - part = TMail::Mail.new - part.set_content_type(content_type, nil, - "charset" => charset || defaults.charset, "name" => filename) - part.set_content_disposition(content_disposition, - "filename" => filename) - - part.content_transfer_encoding = transfer_encoding || "quoted-printable" - case (transfer_encoding || "").downcase - when "base64" then - part.body = TMail::Base64.encode(body) + part.body = TMail::Base64.folding_encode(body) when "quoted-printable" part.body = [body].pack("M*") else |