Normalize line endings in outgoing mail bodies to "\n" #1536 [John Long]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1576 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jamis Buck 2005-06-30 21:40:43 +00:00
parent 813a8b9d2a
commit 24a8cb1e56
3 changed files with 21 additions and 1 deletions

View File

@ -1,5 +1,7 @@
*SVN*
* Normalize line endings in outgoing mail bodies to "\n" #1536 [John Long]
* Allow template to be explicitly specified #1448 [tuxie@dekadance.se]
* Allow specific "multipart/xxx" content-type to be set on multipart messages #1412 [Flurin Egger]

View File

@ -335,9 +335,13 @@ module TMail
}
end
def normalize_line_endings(text)
text.to_s.gsub(/\r\n?/, "\n")
end
def body=( str )
parse_body
@body_port.wopen {|f| f.write str }
@body_port.wopen {|f| f.write normalize_line_endings(str) }
str
end

View File

@ -137,6 +137,14 @@ class TestMailer < ActionMailer::Base
body["recipient"] = recipient
end
def various_newlines(recipient)
recipients recipient
subject "various newlines"
from "test@example.com"
body "line #1\nline #2\rline #3\r\nline #4\r\r" +
"line #5\n\nline#6\r\n\r\nline #7"
end
class <<self
attr_accessor :received_body
end
@ -528,6 +536,12 @@ EOF
assert_equal "text/html", mail.content_type
end
def test_various_newlines
mail = TestMailer.create_various_newlines(@recipient)
assert_equal("line #1\nline #2\nline #3\nline #4\n\n" +
"line #5\n\nline#6\n\nline #7", mail.body)
end
def test_headers_removed_on_smtp_delivery
ActionMailer::Base.delivery_method = :smtp
TestMailer.deliver_cc_bcc(@recipient)