diff options
Diffstat (limited to 'actionmailer')
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 4 | ||||
-rwxr-xr-x | actionmailer/test/mail_service_test.rb | 22 |
2 files changed, 13 insertions, 13 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 27a0c8e19c..b731880570 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -168,9 +168,9 @@ module ActionMailer #:nodoc: def quote_address_if_necessary(address, charset) if Array === address address.map { |a| quote_address_if_necessary(a, charset) } - elsif address =~ /^(\S.+)\s+(<.*>)$/ + elsif address =~ /^(\S.*)\s+(<.*>)$/ address = $2 - phrase = quote_if_necessary($1, charset) + phrase = quote_if_necessary($1.gsub(/^['"](.*)['"]$/, '\1'), charset) "#{phrase} #{address}" else address diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index d5d24b2640..b5d488a02b 100755 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -66,11 +66,11 @@ class TestMailer < ActionMailer::Base def utf8_body(recipient) @recipients = recipient @subject = "testing utf-8 body" - @from = "김치통 <kimchi@example.net.kr>" + @from = "Foo áëô îü <extended@example.net>" @sent_on = Time.local 2004, 12, 12 - @cc = "김치통 <kimchi@example.net.kr>" - @bcc = "김치통 <kimchi@example.net.kr>" - @body = "안녕하세요!" + @cc = "Foo áëô îü <extended@example.net>" + @bcc = "Foo áëô îü <extended@example.net>" + @body = "åœö blah" @charset = "utf-8" end end @@ -277,34 +277,34 @@ EOF end def test_utf8_body_is_not_quoted - @recipient = "김치통 <kimchi@example.net.kr>" + @recipient = "Foo áëô îü <extended@example.net>" expected = new_mail "utf-8" expected.to = TestMailer.quote_address_if_necessary @recipient, "utf-8" expected.subject = "testing utf-8 body" - expected.body = "안녕하세요!" + expected.body = "åœö blah" 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) + assert_match(/åœö blah/, created.encoded) end def test_multiple_utf8_recipients - @recipient = ["김치통 <kimchi@example.net.kr>", "\"Example Recipient\" <me@example.com>"] + @recipient = ["\"Foo áëô îü\" <extended@example.net>", "\"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.body = "åœö blah" 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) + assert_match(/\nFrom: =\?utf-8\?Q\?Foo_.*?\?= <extended@example.net>\r/, created.encoded) + assert_match(/\nTo: =\?utf-8\?Q\?Foo_.*?\?= <extended@example.net>, Example Recipient <me/, created.encoded) end end |