1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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
This commit is contained in:
Jamis Buck 2005-06-03 09:05:06 +00:00
parent 32c0e895bf
commit 887497b0bb
2 changed files with 6 additions and 44 deletions

View file

@ -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

View file

@ -437,12 +437,14 @@ EOF
assert_equal "text/plain", mail.parts[0].content_type
assert_equal "text/html", mail.parts[1].content_type
assert_equal "iso-8859-1", mail.parts[1].sub_header("content-type", "charset")
assert_equal "inline", mail.parts[1].content_disposition
assert_equal "image/jpeg", mail.parts[2].content_type
assert_equal "attachment", mail.parts[2].content_disposition
assert_equal "foo.jpg", mail.parts[2].sub_header("content-disposition", "filename")
assert_equal "foo.jpg", mail.parts[2].sub_header("content-type", "name")
assert_nil mail.parts[2].sub_header("content-type", "charset")
end
def test_implicitly_multipart_messages