diff --git a/actionmailer/README b/actionmailer/README index 6fe883d09b10ad9f895f08c469280d09db29fdf5..d512f04031ed7ff39851c6b1be7e0fcc181ee7c8 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 4b8e2fbc0781b5c4ff29db321c6014d1dcc4f5d6..0a12a61a75661bc3dd024a285fec54ebf4745f8e 100755 --- a/actionmailer/lib/action_mailer/vendor/tmail/facade.rb +++ b/actionmailer/lib/action_mailer/vendor/tmail/facade.rb @@ -261,6 +261,7 @@ def subject( default = nil ) 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 85a80fd29c54dc1dfb76d39f18b4136081f5429c..5aa111ad1f6428fcb69763039460ed6457b1c77c 100755 --- a/actionmailer/lib/action_mailer/vendor/tmail/mail.rb +++ b/actionmailer/lib/action_mailer/vendor/tmail/mail.rb @@ -322,7 +322,7 @@ def each( &block ) 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 d460ece5a11d64d1bc1e1d139460b7589a5ef1ce..d5087f7610b3e5e2d5969437b7a82e676854725d 100644 --- a/actionmailer/lib/action_mailer/vendor/tmail/quoting.rb +++ b/actionmailer/lib/action_mailer/vendor/tmail/quoting.rb @@ -3,24 +3,25 @@ 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 45423a196019ec297cbb3011bfffea34519e6b50..262ce988a24f4b46d44eb42a4b647c51e0183ae9 100755 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -212,5 +212,21 @@ def test_perform_deliveries_flag assert_equal 1, ActionMailer::Base.deliveries.size end + def test_unquote_subject + msg = <