提交 b13efaf9 编写于 作者: J Jamis Buck

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
上级 82f44f31
*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]
......
......@@ -15,7 +15,9 @@ def attachments
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?
......
......@@ -527,6 +527,13 @@ def test_decode_attachment_without_charset
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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册