1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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
This commit is contained in:
Jamis Buck 2005-08-22 20:43:43 +00:00
parent 82f44f3144
commit b13efaf985
3 changed files with 12 additions and 1 deletions

View file

@ -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]

View file

@ -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?

View file

@ -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)