aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xactionmailer/README4
-rwxr-xr-xactionmailer/lib/action_mailer/vendor/tmail/facade.rb1
-rwxr-xr-xactionmailer/lib/action_mailer/vendor/tmail/mail.rb2
-rw-r--r--actionmailer/lib/action_mailer/vendor/tmail/quoting.rb13
-rwxr-xr-xactionmailer/test/mail_service_test.rb16
5 files changed, 27 insertions, 9 deletions
diff --git a/actionmailer/README b/actionmailer/README
index 6fe883d09b..d512f04031 100755
--- a/actionmailer/README
+++ b/actionmailer/README
@@ -66,13 +66,13 @@ Example:
def receive(email)
page = Page.find_by_address(email.to.first)
page.emails.create(
- :subject => email.unquoted_subject, :body => email.unquoted_body_with_all_parts
+ :subject => email.subject, :body => email.body
)
if email.has_attachments?
for attachment in email.attachments
page.attachments.create({
- :file => attachment, :description => email.unquoted_subject
+ :file => attachment, :description => email.subject
})
end
end
diff --git a/actionmailer/lib/action_mailer/vendor/tmail/facade.rb b/actionmailer/lib/action_mailer/vendor/tmail/facade.rb
index 4b8e2fbc07..0a12a61a75 100755
--- a/actionmailer/lib/action_mailer/vendor/tmail/facade.rb
+++ b/actionmailer/lib/action_mailer/vendor/tmail/facade.rb
@@ -261,6 +261,7 @@ module TMail
default
end
end
+ alias quoted_subject subject
def subject=( str )
set_string_attr 'Subject', str
diff --git a/actionmailer/lib/action_mailer/vendor/tmail/mail.rb b/actionmailer/lib/action_mailer/vendor/tmail/mail.rb
index 85a80fd29c..5aa111ad1f 100755
--- a/actionmailer/lib/action_mailer/vendor/tmail/mail.rb
+++ b/actionmailer/lib/action_mailer/vendor/tmail/mail.rb
@@ -322,7 +322,7 @@ module TMail
body_port().ropen {|f| f.each(&block) }
end
- def body
+ def quoted_body
parse_body
@body_port.ropen {|f|
return f.read
diff --git a/actionmailer/lib/action_mailer/vendor/tmail/quoting.rb b/actionmailer/lib/action_mailer/vendor/tmail/quoting.rb
index d460ece5a1..d5087f7610 100644
--- a/actionmailer/lib/action_mailer/vendor/tmail/quoting.rb
+++ b/actionmailer/lib/action_mailer/vendor/tmail/quoting.rb
@@ -3,24 +3,25 @@ require 'base64'
module TMail
class Mail
- def unquoted_subject(to_charset = 'utf-8')
- Unquoter.unquote_and_convert_to(subject || "", to_charset)
+ def subject(to_charset = 'utf-8')
+ Unquoter.unquote_and_convert_to(quoted_subject || "", to_charset)
end
def unquoted_body(to_charset = 'utf-8')
- Unquoter.unquote_and_convert_to(body || "", to_charset, header["content-type"]["charset"])
+ Unquoter.unquote_and_convert_to(quoted_body || "", to_charset, header["content-type"]["charset"])
end
- def unquoted_body_with_all_parts(to_charset = 'utf-9', &block)
+ def body(to_charset = 'utf-8', &block)
attachment_presenter = block || Proc.new { |file_name| "Attachment: #{file_name}\n" }
if multipart?
parts.collect { |part|
part.header["content-type"].main_type == "text" ?
- part.unquoted_body : attachment_presenter.call(part.header["content-type"].params["name"])
+ part.unquoted_body(to_charset) :
+ attachment_presenter.call(part.header["content-type"].params["name"])
}.join
else
- unquoted_body
+ unquoted_body(to_charset)
end
end
end
diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb
index 45423a1960..262ce988a2 100755
--- a/actionmailer/test/mail_service_test.rb
+++ b/actionmailer/test/mail_service_test.rb
@@ -212,5 +212,21 @@ class ActionMailerTest < Test::Unit::TestCase
assert_equal 1, ActionMailer::Base.deliveries.size
end
+ def test_unquote_subject
+ msg = <<EOF
+From: me@example.com
+Subject: =?utf-8?Q?testing_testing_=D6=A4?=
+Content-Type: text/plain; charset=iso-8859-1
+
+This_is_a_test
+2 + 2 =3D 4
+EOF
+ mail = TMail::Mail.parse(msg)
+ assert_equal "testing testing \326\244", mail.subject
+ assert_equal "=?utf-8?Q?testing_testing_=D6=A4?=", mail.quoted_subject
+ assert_equal "This is a test\n2 + 2 = 4\n", mail.body
+ assert_equal "This_is_a_test\n2 + 2 =3D 4\n", mail.quoted_body
+ end
+
end