diff options
author | Jamis Buck <jamis@37signals.com> | 2005-08-22 20:43:43 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2005-08-22 20:43:43 +0000 |
commit | b13efaf9855d5dc060972dae11ef97ab28c93e44 (patch) | |
tree | 4c3a9573f1e8d0c622a061698022fcc22b7cf353 | |
parent | 82f44f314402cbd4627caa1c8ba24c35a5c875dd (diff) | |
download | rails-b13efaf9855d5dc060972dae11ef97ab28c93e44.tar.gz rails-b13efaf9855d5dc060972dae11ef97ab28c93e44.tar.bz2 rails-b13efaf9855d5dc060972dae11ef97ab28c93e44.zip |
Look at content-location header (if available) to determine filename of attachments #1670
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2034 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | actionmailer/CHANGELOG | 2 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/vendor/tmail/attachments.rb | 4 | ||||
-rwxr-xr-x | actionmailer/test/mail_service_test.rb | 7 |
3 files changed, 12 insertions, 1 deletions
diff --git a/actionmailer/CHANGELOG b/actionmailer/CHANGELOG index 7ece8703f2..1d99448f62 100644 --- a/actionmailer/CHANGELOG +++ b/actionmailer/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Look at content-location header (if available) to determine filename of attachments #1670 + * ActionMailer::Base.deliver(email) had been accidentally removed, but was documented in the Rails book #1849 * Fix problem with sendmail delivery where headers should be delimited by \n characters instead of \r\n, which confuses some mail readers #1742 [Kent Sibilev] diff --git a/actionmailer/lib/action_mailer/vendor/tmail/attachments.rb b/actionmailer/lib/action_mailer/vendor/tmail/attachments.rb index e402b0545f..cdc4ba8631 100644 --- a/actionmailer/lib/action_mailer/vendor/tmail/attachments.rb +++ b/actionmailer/lib/action_mailer/vendor/tmail/attachments.rb @@ -15,7 +15,9 @@ module TMail parts.collect { |part| if part.header["content-type"].main_type != "text" content = part.body # unquoted automatically by TMail#body - file_name = part.sub_header("content-type", "name") || + file_name = (part['content-location'] && + part['content-location'].body) || + part.sub_header("content-type", "name") || part.sub_header("content-disposition", "filename") next if file_name.blank? || content.blank? diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index 1cabb06c53..97bdcaa1f8 100755 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -527,6 +527,13 @@ EOF assert_equal 1026, attachment.read.length end + def test_attachment_using_content_location + fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email12") + mail = TMail::Mail.parse(fixture) + assert_equal 1, mail.attachments.length + assert_equal "Photo25.jpg", mail.attachments.first.original_filename + end + def test_decode_part_without_content_type fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email4") mail = TMail::Mail.parse(fixture) |