commit 1935ba24f5d9d66ba8865ed0abeefefbf2c45add Author: Felix Scha╠łfer Date: Fri May 23 13:36:35 2014 +0200 Better html-only emails handling #16962 diff --git a/Gemfile b/Gemfile index dcf88ae..eb498f2 100644 --- a/Gemfile +++ b/Gemfile @@ -8,6 +8,7 @@ gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby] gem "builder", "3.0.0" gem "request_store" gem "mime-types" +gem "loofah" # Optional gem for LDAP authentication group :ldap do diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb index 1b46005..8d4715e 100644 --- a/app/models/mail_handler.rb +++ b/app/models/mail_handler.rb @@ -428,8 +428,7 @@ class MailHandler < ActionMailer::Base # strip html tags and remove doctype directive if parts.any? {|p| p.mime_type == 'text/html'} - @plain_text_body = strip_tags(@plain_text_body.strip) - @plain_text_body.sub! %r{^ + -This is a html-only email.
+This is a html-only email.

With a title

and a paragraph.

diff --git a/test/unit/mail_handler_test.rb b/test/unit/mail_handler_test.rb index 96d16d8..a60bd32 100644 --- a/test/unit/mail_handler_test.rb +++ b/test/unit/mail_handler_test.rb @@ -763,7 +763,7 @@ class MailHandlerTest < ActiveSupport::TestCase assert !issue.new_record? issue.reload assert_equal 'HTML email', issue.subject - assert_equal 'This is a html-only email.', issue.description + assert_equal "This is a html-only email.\r\nWith a title\r\n\r\nand a paragraph.", issue.description end test "truncate emails with no setting should add the entire email into the issue" do