aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/lib/action_mailer
diff options
context:
space:
mode:
authorJosé Valim and Mikel Lindsaar <raasdnil@gmail.com>2010-01-22 12:46:19 +1100
committerJosé Valim and Mikel Lindsaar <raasdnil@gmail.com>2010-01-22 12:46:19 +1100
commit12c001fec449864db64eca9ba3a477a7da30b2ba (patch)
treeef1712cee7d77b9cc069fcdf24fc4d71622bf779 /actionmailer/lib/action_mailer
parent3829f9ecfd6fcd54edbc15f624ee3b68f6dae135 (diff)
downloadrails-12c001fec449864db64eca9ba3a477a7da30b2ba.tar.gz
rails-12c001fec449864db64eca9ba3a477a7da30b2ba.tar.bz2
rails-12c001fec449864db64eca9ba3a477a7da30b2ba.zip
Updating deprecated API to sanitize old style attachments hash to work with new mail.attachments method
Diffstat (limited to 'actionmailer/lib/action_mailer')
-rw-r--r--actionmailer/lib/action_mailer/deprecated_api.rb45
1 files changed, 35 insertions, 10 deletions
diff --git a/actionmailer/lib/action_mailer/deprecated_api.rb b/actionmailer/lib/action_mailer/deprecated_api.rb
index d096ea6180..19c94aee8d 100644
--- a/actionmailer/lib/action_mailer/deprecated_api.rb
+++ b/actionmailer/lib/action_mailer/deprecated_api.rb
@@ -30,23 +30,48 @@ module ActionMailer
super # Run deprecation hooks
params = { :content_type => params } if String === params
-
- if filename = params.delete(:filename)
- content_disposition = "attachment; filename=\"#{File.basename(filename)}\""
+
+ if params[:filename]
+ params = normalize_file_hash(params)
else
- content_disposition = "attachment"
+ params = normalize_nonfile_hash(params)
end
-
- params[:content] = params.delete(:data) if params[:data]
-
- params = { :content_disposition => content_disposition,
- :content_transfer_encoding => "base64" }.merge(params)
-
part(params, &block)
end
private
+ def normalize_nonfile_hash(params)
+ content_disposition = "attachment;"
+
+ mime_type = params.delete(:mime_type)
+
+ if content_type = params.delete(:content_type)
+ content_type = "#{mime_type || content_type};"
+ end
+
+ params[:body] = params.delete(:data) if params[:data]
+
+ { :content_type => content_type,
+ :content_disposition => content_disposition }.merge(params)
+ end
+
+ def normalize_file_hash(params)
+ filename = File.basename(params.delete(:filename))
+ content_disposition = "attachment; filename=\"#{File.basename(filename)}\""
+
+ mime_type = params.delete(:mime_type)
+
+ if (content_type = params.delete(:content_type)) && (content_type !~ /filename=/)
+ content_type = "#{mime_type || content_type}; filename=\"#{filename}\""
+ end
+
+ params[:body] = params.delete(:data) if params[:data]
+
+ { :content_type => content_type,
+ :content_disposition => content_disposition }.merge(params)
+ end
+
def create_mail #:nodoc:
m = @message