aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer
diff options
context:
space:
mode:
authorJamis Buck <jamis@37signals.com>2005-06-30 21:40:43 +0000
committerJamis Buck <jamis@37signals.com>2005-06-30 21:40:43 +0000
commit24a8cb1e5600d95a51323982e4d7508eb22c8b1f (patch)
tree130932096e9fbda51737d9e208e177112c289828 /actionmailer
parent813a8b9d2a17e1f0d7f7dfdcf04a79c94722e283 (diff)
downloadrails-24a8cb1e5600d95a51323982e4d7508eb22c8b1f.tar.gz
rails-24a8cb1e5600d95a51323982e4d7508eb22c8b1f.tar.bz2
rails-24a8cb1e5600d95a51323982e4d7508eb22c8b1f.zip
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
Diffstat (limited to 'actionmailer')
-rw-r--r--actionmailer/CHANGELOG2
-rwxr-xr-xactionmailer/lib/action_mailer/vendor/tmail/mail.rb6
-rwxr-xr-xactionmailer/test/mail_service_test.rb14
3 files changed, 21 insertions, 1 deletions
diff --git a/actionmailer/CHANGELOG b/actionmailer/CHANGELOG
index eac4caf81a..93995081f0 100644
--- a/actionmailer/CHANGELOG
+++ b/actionmailer/CHANGELOG
@@ -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]
diff --git a/actionmailer/lib/action_mailer/vendor/tmail/mail.rb b/actionmailer/lib/action_mailer/vendor/tmail/mail.rb
index 9111a65042..f4a42df19b 100755
--- a/actionmailer/lib/action_mailer/vendor/tmail/mail.rb
+++ b/actionmailer/lib/action_mailer/vendor/tmail/mail.rb
@@ -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
diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb
index ce5702db07..f5402c6617 100755
--- a/actionmailer/test/mail_service_test.rb
+++ b/actionmailer/test/mail_service_test.rb
@@ -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)