3
4
5
6
7
8
9
10
11
12
13
|
# File 'app/helpers/rails_mail/emails_helper.rb', line 3
def prepare_email_html(raw_html)
doc = Nokogiri::HTML::DocumentFragment.parse(raw_html)
doc.css("a[href]").each do |a|
a.set_attribute("target", "_blank")
a.set_attribute("rel", "noopener noreferrer")
a.set_attribute("data-turbo", "false")
end
sanitize(doc.to_html,
tags: ActionView::Base.sanitized_allowed_tags + [ "table", "tbody", "tr", "td", "th", "thead", "tfoot" ],
attributes: ActionView::Base.sanitized_allowed_attributes + [ "style", "target", "data-turbo" ])
end
|