From f7540aa52f1f2eb97cd111890187132871463cf1 Mon Sep 17 00:00:00 2001 From: ValdikSS Date: Mon, 25 Apr 2022 19:57:56 +0300 Subject: [PATCH] FIX: properly clean Thunderbird emails, don't remove links (#16543) Mozilla Thunderbird email client add links into HTML as follows: `

The link: https://google.com

` Current filtering rules strip out the link, leaving only `

The link:

`. Properly strip only unnecessary information: quote prefix, signature, forwarded message header. --- lib/email/receiver.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/email/receiver.rb b/lib/email/receiver.rb index e03368a3616..ff01667ef19 100644 --- a/lib/email/receiver.rb +++ b/lib/email/receiver.rb @@ -471,7 +471,9 @@ module Email def extract_from_mozilla(doc) # Mozilla (Thunderbird ?) properly identifies signature and forwarded emails # Remove them and anything that comes after - elided = doc.css("*[class^='moz-'], *[class^='moz-'] ~ *").remove + elided = doc.css("*[class^='moz-cite'], *[class^='moz-cite'] ~ *, " \ + "*[class^='moz-signature'], *[class^='moz-signature'] ~ *, " \ + "*[class^='moz-forward'], *[class^='moz-forward'] ~ *").remove to_markdown(doc.to_html, elided.to_html) end