Skip to content

Commit

Permalink
added boundary string when using multipart/alternative (fix rails#3090)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennyj committed Oct 20, 2011
1 parent 960882f commit 211b2d4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions actionmailer/lib/action_mailer/old_api.rb
Expand Up @@ -167,6 +167,7 @@ def create_mail
if real_content_type =~ /multipart/ if real_content_type =~ /multipart/
ctype_attrs.delete "charset" ctype_attrs.delete "charset"
m.content_type([main_type, sub_type, ctype_attrs]) m.content_type([main_type, sub_type, ctype_attrs])
m.body.boundary = ctype_attrs["boundary"] if ctype_attrs.has_key?("boundary")
end end
end end


Expand Down Expand Up @@ -206,8 +207,8 @@ def create_parts
@parts << create_inline_part(render(:template => template), template.mime_type) @parts << create_inline_part(render(:template => template), template.mime_type)
end end


if @parts.size > 1 if @parts.size > 1 && @content_type !~ /^multipart/
@content_type = "multipart/alternative" if @content_type !~ /^multipart/ @content_type = Mail::ContentTypeField.with_boundary("multipart/alternative").value
end end


# If this is a multipart e-mail add the mime_version if it is not # If this is a multipart e-mail add the mime_version if it is not
Expand Down
2 changes: 1 addition & 1 deletion actionmailer/test/old_base/mail_service_test.rb
Expand Up @@ -935,7 +935,7 @@ def test_implicitly_multipart_messages_with_custom_order
def test_implicitly_multipart_messages_with_charset def test_implicitly_multipart_messages_with_charset
mail = TestMailer.implicitly_multipart_example(@recipient, 'iso-8859-1') mail = TestMailer.implicitly_multipart_example(@recipient, 'iso-8859-1')


assert_equal "multipart/alternative", mail.header['content-type'].content_type assert_match %r{^multipart/alternative; boundary="--==_mimepart_.+"$}, mail.header['content-type'].to_s


assert_equal 'iso-8859-1', mail.parts[0].content_type_parameters[:charset] assert_equal 'iso-8859-1', mail.parts[0].content_type_parameters[:charset]
assert_equal 'iso-8859-1', mail.parts[1].content_type_parameters[:charset] assert_equal 'iso-8859-1', mail.parts[1].content_type_parameters[:charset]
Expand Down

0 comments on commit 211b2d4

Please sign in to comment.