From a0386655a6d61e00969ffdb981e93aa101a3272b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Fri, 30 Mar 2018 10:41:32 +0200 Subject: [PATCH] Add support to elide content from ProtonMail emails --- lib/email/receiver.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/email/receiver.rb b/lib/email/receiver.rb index 09c1d2540ac..eaa9050c7a9 100644 --- a/lib/email/receiver.rb +++ b/lib/email/receiver.rb @@ -301,6 +301,7 @@ module Email [:exchange, /name="message(Body|Reply)Section"/], [:apple_mail, /id="AppleMailSignature"/], [:mozilla, /class="moz-/], + [:protonmail, /class="protonmail_/], ] def extract_from_gmail(html) @@ -351,6 +352,13 @@ module Email to_markdown(doc.to_html, elided.to_html) end + def extract_from_protonmail(html) + doc = Nokogiri::HTML.fragment(html) + # Removes anything that has a class starting with "protonmail_" and everything after that + elided = doc.css("*[class^='protonmail_'], *[class^='protonmail_'] ~ *").remove + to_markdown(doc.to_html, elided.to_html) + end + def trim_reply_and_extract_elided(text) return [text, ""] if @opts[:skip_trimming] EmailReplyTrimmer.trim(text, true)