aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-04-13 17:49:24 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-04-13 17:49:24 +0000
commit54cc595dff2564d6cb48c40709637170bca79837 (patch)
treebe23790b9eae6e8a4d943674b9d82cd57f924a61 /actionmailer
parentf3e5e07982946f05b9826d5701aa95359bb5a10f (diff)
downloadrails-54cc595dff2564d6cb48c40709637170bca79837.tar.gz
rails-54cc595dff2564d6cb48c40709637170bca79837.tar.bz2
rails-54cc595dff2564d6cb48c40709637170bca79837.zip
Improved address header processing
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1161 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionmailer')
-rw-r--r--actionmailer/lib/action_mailer/base.rb4
-rwxr-xr-xactionmailer/test/mail_service_test.rb22
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