Skip to content

A platform for community discussion. Free, open, simple.

FIX: don't extract divs with a 'gmail_default' class

Régis Hanol2d561a0422e8
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