From 887497b0bb8725018837ddce162363c5f0e3f0b9 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Fri, 3 Jun 2005 09:05:06 +0000 Subject: 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 --- actionmailer/lib/action_mailer/part.rb | 48 +++------------------------------- 1 file changed, 4 insertions(+), 44 deletions(-) (limited to 'actionmailer/lib/action_mailer') 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 -- cgit v1.2.3