mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: less aggressive gmail eliding
This commit is contained in:
@@ -301,7 +301,7 @@ module Email
|
|||||||
end
|
end
|
||||||
|
|
||||||
HTML_EXTRACTERS ||= [
|
HTML_EXTRACTERS ||= [
|
||||||
[:gmail, /class="gmail_(?!default)/],
|
[:gmail, /class="gmail_(signature|extra)/],
|
||||||
[:outlook, /id="(divRplyFwdMsg|Signature)"/],
|
[:outlook, /id="(divRplyFwdMsg|Signature)"/],
|
||||||
[:word, /class="WordSection1"/],
|
[:word, /class="WordSection1"/],
|
||||||
[:exchange, /name="message(Body|Reply)Section"/],
|
[:exchange, /name="message(Body|Reply)Section"/],
|
||||||
@@ -313,9 +313,8 @@ module Email
|
|||||||
]
|
]
|
||||||
|
|
||||||
def extract_from_gmail(doc)
|
def extract_from_gmail(doc)
|
||||||
# GMail adds a bunch of 'gmail_' prefixed classes like: gmail_signature, gmail_extra, gmail_quote
|
# GMail adds a bunch of 'gmail_' prefixed classes like: gmail_signature, gmail_extra, gmail_quote, gmail_default...
|
||||||
# Just elide them all except for 'gmail_default'
|
elided = doc.css(".gmail_signature, .gmail_extra").remove
|
||||||
elided = doc.css("*[class^='gmail_']:not([class*='gmail_default'])").remove
|
|
||||||
to_markdown(doc.to_html, elided.to_html)
|
to_markdown(doc.to_html, elided.to_html)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
2
spec/fixtures/emails/gmail_html_reply.eml
vendored
2
spec/fixtures/emails/gmail_html_reply.eml
vendored
@@ -11,7 +11,7 @@ Content-Transfer-Encoding: quoted-printable
|
|||||||
<div dir="auto">
|
<div dir="auto">
|
||||||
<p>This is a <b>GMAIL</b> reply ;)</p>
|
<p>This is a <b>GMAIL</b> reply ;)</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="gmail_quote">
|
<div class="gmail_signature">
|
||||||
<p>This is the <i>elided</i> part!</p>
|
<p>This is the <i>elided</i> part!</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user