Browse files

Dont quote the body

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1144 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 256e800 commit a67beac9d0db8e7dd88267ac5eeefc49ffbd46ce @dhh dhh committed Apr 11, 2005
Showing with 29 additions and 3 deletions.
  1. +4 −3 actionmailer/lib/action_mailer/base.rb
  2. +25 −0 actionmailer/test/mail_service_test.rb
View
7 actionmailer/lib/action_mailer/base.rb
@@ -100,9 +100,9 @@ def initialize
class << self
def method_missing(method_symbol, *parameters)#:nodoc:
case method_symbol.id2name
- when /^create_([_a-z]*)/
+ when /^create_([_a-z]\w*)/
create_from_action($1, *parameters)
- when /^deliver_([_a-z]*)/
+ when /^deliver_([_a-z]\w*)/
begin
deliver(send("create_" + $1, *parameters))
rescue Object => e
@@ -121,7 +121,8 @@ def create(to, subject, body, from, timestamp = nil, headers = {},
charset = @@default_charset
) #:nodoc:
m = TMail::Mail.new
- m.subject, m.body = quote_any_if_necessary(charset, subject, body)
+ m.body = body
+ m.subject, = quote_any_if_necessary(charset, subject)
m.to, m.from = quote_any_address_if_necessary(charset, to, from)
m.date = timestamp.respond_to?("to_time") ? timestamp.to_time : (timestamp || Time.now)
View
25 actionmailer/test/mail_service_test.rb
@@ -63,6 +63,16 @@ def extended_headers(recipient)
@charset = "iso-8859-1"
end
+ def utf8_body(recipient)
+ @recipients = recipient
+ @subject = "testing utf-8 body"
+ @from = "김치통 <kimchi@example.net.kr>"
+ @sent_on = Time.local 2004, 12, 12
+ @cc = "김치통 <kimchi@example.net.kr>"
+ @bcc = "김치통 <kimchi@example.net.kr>"
+ @body = "안녕하세요!"
+ @charset = "utf-8"
+ end
end
TestMailer.template_root = File.dirname(__FILE__) + "/fixtures"
@@ -265,6 +275,21 @@ def test_extended_headers
assert_not_nil ActionMailer::Base.deliveries.first
assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded
end
+
+ def test_utf8_body_is_not_quoted
+ @recipient = "김치통 <kimchi@example.net.kr>"
+ expected = new_mail "utf-8"
+ expected.to = TestMailer.quote_address_if_necessary @recipient, "utf-8"
+ expected.subject = "testing utf-8 body"
+ expected.body = "안녕하세요!"
+ expected.from = TestMailer.quote_address_if_necessary @recipient, "utf-8"
+ expected.cc = TestMailer.quote_address_if_necessary @recipient, "utf-8"
+ expected.bcc = TestMailer.quote_address_if_necessary @recipient, "utf-8"
+ expected.date = Time.local 2004, 12, 12
+
+ created = TestMailer.create_utf8_body @recipient
+ assert_match(/안녕하세요!/, created.encoded)
+ end
end

0 comments on commit a67beac

Please sign in to comment.