From 2d561a0422e8a0decacefd4c9bae5e79dbb860dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Thu, 3 May 2018 12:29:21 +0200 Subject: [PATCH] FIX: don't extract divs with a 'gmail_default' class --- lib/email/receiver.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/email/receiver.rb b/lib/email/receiver.rb index 8de43f4b3ab..4cbcfb175c0 100644 --- a/lib/email/receiver.rb +++ b/lib/email/receiver.rb @@ -296,21 +296,21 @@ module Email end HTML_EXTRACTERS ||= [ - [:gmail, / class="gmail_/], - [:outlook, / id="(divRplyFwdMsg|Signature)"/], - [:word, / class="WordSection1"/], - [:exchange, / name="message(Body|Reply)Section"/], - [:apple_mail, / id="AppleMailSignature"/], - [:mozilla, / class="moz-/], - [:protonmail, / class="protonmail_/], - [:zimbra, / data-marker="__/], + [:gmail, /class="gmail_(?!default)/], + [:outlook, /id="(divRplyFwdMsg|Signature)"/], + [:word, /class="WordSection1"/], + [:exchange, /name="message(Body|Reply)Section"/], + [:apple_mail, /id="AppleMailSignature"/], + [:mozilla, /class="moz-/], + [:protonmail, /class="protonmail_/], + [:zimbra, /data-marker="__/], [:newton, /(id|class)="cm_/], ] def extract_from_gmail(doc) # GMail adds a bunch of 'gmail_' prefixed classes like: gmail_signature, gmail_extra, gmail_quote - # Just elide them all - elided = doc.css("*[class^='gmail_']").remove + # Just elide them all except for 'gmail_default' + elided = doc.css("*[class^='gmail_']:not([class*='gmail_default'])").remove to_markdown(doc.to_html, elided.to_html) end