Feature #16962 » 16962.patch
| Gemfile | ||
|---|---|---|
| 8 | 8 |
gem "builder", "3.0.0" |
| 9 | 9 |
gem "request_store" |
| 10 | 10 |
gem "mime-types" |
| 11 |
gem "loofah" |
|
| 11 | 12 | |
| 12 | 13 |
# Optional gem for LDAP authentication |
| 13 | 14 |
group :ldap do |
| app/models/mail_handler.rb | ||
|---|---|---|
| 428 | 428 | |
| 429 | 429 |
# strip html tags and remove doctype directive |
| 430 | 430 |
if parts.any? {|p| p.mime_type == 'text/html'}
|
| 431 |
@plain_text_body = strip_tags(@plain_text_body.strip) |
|
| 432 |
@plain_text_body.sub! %r{^<!DOCTYPE .*$}, ''
|
|
| 431 |
@plain_text_body = Loofah.document(@plain_text_body).to_text |
|
| 433 | 432 |
end |
| 434 | 433 | |
| 435 | 434 |
@plain_text_body |
| test/fixtures/mail_handler/ticket_html_only.eml | ||
|---|---|---|
| 15 | 15 |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| 16 | 16 |
<html> |
| 17 | 17 |
<head> |
| 18 |
<style>p {font-size:12.0pt;}</style>
|
|
| 18 | 19 |
</head> |
| 19 | 20 |
<body bgcolor="#ffffff" text="#000000"> |
| 20 |
This is a <b>html-only</b> email.<br> |
|
| 21 |
This is a <b>html-only</b> email.<br><h1>With a title</h1><p>and a paragraph.</p>
|
|
| 21 | 22 |
</body> |
| 22 | 23 |
</html> |
| test/unit/mail_handler_test.rb | ||
|---|---|---|
| 763 | 763 |
assert !issue.new_record? |
| 764 | 764 |
issue.reload |
| 765 | 765 |
assert_equal 'HTML email', issue.subject |
| 766 |
assert_equal 'This is a html-only email.', issue.description
|
|
| 766 |
assert_equal "This is a html-only email.\r\nWith a title\r\n\r\nand a paragraph.", issue.description
|
|
| 767 | 767 |
end |
| 768 | 768 | |
| 769 | 769 |
test "truncate emails with no setting should add the entire email into the issue" do |