diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-04-13 04:44:58 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-04-13 04:44:58 +0000 |
commit | d5cadfc1108728635055d476eff7b34c975705d6 (patch) | |
tree | 8fd34ee0fc1512d5b0cbfcfd5aa62b06f00a9d94 /actionmailer | |
parent | 6f5fcc44699e50b54301d2005180e443da45be8f (diff) | |
download | rails-d5cadfc1108728635055d476eff7b34c975705d6.tar.gz rails-d5cadfc1108728635055d476eff7b34c975705d6.tar.bz2 rails-d5cadfc1108728635055d476eff7b34c975705d6.zip |
Address parsing failed when the "to" (or "cc", or whatever) was an array. It was also too restrictive in the formats of the addresses #1097 [Jamis]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1149 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionmailer')
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 4 | ||||
-rwxr-xr-x | actionmailer/test/mail_service_test.rb | 18 |
2 files changed, 20 insertions, 2 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index a20197c754..27a0c8e19c 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -166,7 +166,9 @@ module ActionMailer #:nodoc: # it needs to be. This allows extended characters to be used in the # "to", "from", "cc", and "bcc" headers. def quote_address_if_necessary(address, charset) - if address =~ /^([^<>\s]+) (<.*>)$/ + if Array === address + address.map { |a| quote_address_if_necessary(a, charset) } + elsif address =~ /^(\S.+)\s+(<.*>)$/ address = $2 phrase = quote_if_necessary($1, charset) "#{phrase} #{address}" diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index bebbdba473..d5d24b2640 100755 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -289,7 +289,23 @@ EOF created = TestMailer.create_utf8_body @recipient assert_match(/안녕하세요!/, created.encoded) - end + end + + def test_multiple_utf8_recipients + @recipient = ["김치통 <kimchi@example.net.kr>", "\"Example Recipient\" <me@example.com>"] + 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.first, "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(/\nFrom: =\?.*?\?= <kimchi@example.net.kr>\r/, created.encoded) + assert_match(/\nTo: =\?.*?\?= <kimchi.*?>, Example Recipient <me/, created.encoded) + end end |