Feature #16962 » 16962.patch
| Gemfile | ||
|---|---|---|
|
gem "builder", "3.0.0"
|
||
|
gem "request_store"
|
||
|
gem "mime-types"
|
||
|
gem "loofah"
|
||
|
# Optional gem for LDAP authentication
|
||
|
group :ldap do
|
||
| app/models/mail_handler.rb | ||
|---|---|---|
|
# 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{^<!DOCTYPE .*$}, ''
|
||
|
@plain_text_body = Loofah.document(@plain_text_body).to_text
|
||
|
end
|
||
|
@plain_text_body
|
||
| test/fixtures/mail_handler/ticket_html_only.eml | ||
|---|---|---|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||
|
<html>
|
||
|
<head>
|
||
|
<style>p {font-size:12.0pt;}</style>
|
||
|
</head>
|
||
|
<body bgcolor="#ffffff" text="#000000">
|
||
|
This is a <b>html-only</b> email.<br>
|
||
|
This is a <b>html-only</b> email.<br><h1>With a title</h1><p>and a paragraph.</p>
|
||
|
</body>
|
||
|
</html>
|
||
| test/unit/mail_handler_test.rb | ||
|---|---|---|
|
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
|
||