aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionmailer/CHANGELOG2
-rw-r--r--actionmailer/lib/action_mailer/vendor/tmail/attachments.rb4
-rwxr-xr-xactionmailer/test/mail_service_test.rb7
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)