Skip to content

Commit

Permalink
Fixed that no body charset would be set when there are attachments pr…
Browse files Browse the repository at this point in the history
…esent [#740 state:commited] (Paweł Kondzior)
  • Loading branch information
dhh committed Nov 15, 2008
1 parent 44c3b86 commit f46780a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions actionmailer/CHANGELOG
@@ -1,3 +1,8 @@
*2.3.0/3.0*

* Fixed that no body charset would be set when there are attachments present #740 [Paweł Kondzior]


*2.2.1 [RC2] (November 14th, 2008)*

* Turn on STARTTLS if it is available in Net::SMTP (added in Ruby 1.8.7) and the SMTP server supports it (This is required for Gmail's SMTP server) #1336 [Grant Hollingworth]
Expand Down
6 changes: 5 additions & 1 deletion actionmailer/lib/action_mailer/part_container.rb
Expand Up @@ -41,7 +41,11 @@ def attachment(params, &block)
private

def parse_content_type(defaults=nil)
return [defaults && defaults.content_type, {}] if content_type.blank?
if content_type.blank?
return defaults ?
[ defaults.content_type, { 'charset' => defaults.charset } ] :
[ nil, {} ]
end
ctype, *attrs = content_type.split(/;\s*/)
attrs = attrs.inject({}) { |h,s| k,v = s.split(/=/, 2); h[k] = v; h }
[ctype, {"charset" => charset || defaults && defaults.charset}.merge(attrs)]
Expand Down
2 changes: 2 additions & 0 deletions actionmailer/test/mail_service_test.rb
Expand Up @@ -915,6 +915,8 @@ def test_deliver_with_mail_object
def test_multipart_with_template_path_with_dots
mail = FunkyPathMailer.create_multipart_with_template_path_with_dots(@recipient)
assert_equal 2, mail.parts.length
assert_equal 'text/plain', mail.parts[0].content_type
assert_equal 'utf-8', mail.parts[0].charset
end

def test_custom_content_type_attributes
Expand Down

0 comments on commit f46780a

Please sign in to comment.