mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
FEATURE: new 'trim_incoming_emails' site setting (#12874)
This setting allows admin to de/activate automatic trimming of incoming email. There are instances where it does wonders in trimming all the garbage content and other instances where it's so bad that it trims the most important part of the email. FIX: don't remove hidden content using the style attribute when converting HTML to Markdown. The regexp used was doing more harm than good. It was way too broad. FIX: properly elide signatures from emails sent with Front App. This is fairly safe as Front App nicely identifies signatures in the HTML part.
This commit is contained in:
@ -37,11 +37,8 @@ class HtmlToMarkdown
|
||||
@doc.traverse { |node| node.remove if !allowed.include?(node.name) }
|
||||
end
|
||||
|
||||
HIDDEN_STYLES ||= /(display\s*:\s*none)|(visibility\s*:\s*hidden)|(opacity\s*:\s*0)|(transform\s*:\s*scale\(0\))|((width|height)\s*:\s*0)/i
|
||||
|
||||
def remove_hidden!(doc)
|
||||
@doc.css("[hidden]").remove
|
||||
@doc.css("[style]").each { |n| n.remove if n["style"][HIDDEN_STYLES] }
|
||||
@doc.css("img[width]").each { |n| n.remove if n["width"].to_i <= 0 }
|
||||
@doc.css("img[height]").each { |n| n.remove if n["height"].to_i <= 0 }
|
||||
end
|
||||
|
Reference in New Issue
Block a user