From 06052cb34c578879e2e835321eee9b14e76adf9e Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Mon, 4 Jul 2005 16:11:22 +0000 Subject: Avoid adding nil values to mail headers #1392 git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1666 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionmailer/lib/action_mailer/part.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'actionmailer/lib/action_mailer') diff --git a/actionmailer/lib/action_mailer/part.rb b/actionmailer/lib/action_mailer/part.rb index b47961a744..7b9260f225 100644 --- a/actionmailer/lib/action_mailer/part.rb +++ b/actionmailer/lib/action_mailer/part.rb @@ -40,9 +40,9 @@ module ActionMailer # non-attachment parts) if content_disposition == "attachment" part.set_content_type(content_type || defaults.content_type, nil, - "charset" => nil, - "name" => filename) - part.set_content_disposition(content_disposition, "filename" => filename) + squish("charset" => nil, "name" => filename)) + part.set_content_disposition(content_disposition, + squish("filename" => filename)) else part.set_content_type(content_type || defaults.content_type, nil, "charset" => (charset || defaults.charset)) @@ -65,9 +65,14 @@ module ActionMailer part.set_content_type(content_type, nil, { "charset" => charset }) if content_type =~ /multipart/ end - part end + + private + + def squish(values={}) + values.delete_if { |k,v| v.nil? } + end end end -- cgit v1.2.3