Fix: parse verification mail (#3864)

Email parsing logic was stripping of HTML tables which was causing the issue in this case.

Fixes: #3731
This commit is contained in:
Tejaswini Chile
2022-01-28 05:15:26 +05:30
committed by GitHub
parent 13eaff156a
commit 1467a8fa33
3 changed files with 23 additions and 4 deletions

View File

@@ -15,7 +15,6 @@ class HtmlParser
def filter_replies!
document.xpath('//blockquote').each { |n| n.replace('> ') }
document.xpath('//table').each(&:remove)
end
def filtered_html

View File

@@ -27,15 +27,16 @@ class MailPresenter < SimpleDelegator
end
# returns encoded mail body text_part if available.
# returns encoded mail body as it is if mail_part not available.
# else returns parsed the html body if contains text/html content.
def select_body(mail_part)
return '' unless mail_part
return encoded_mail_body unless mail_part
decoded = encode_to_unicode(mail_part.decoded)
if mail.text_part
decoded
elsif (mail.content_type || '').include? 'text/html'
elsif html_mail_body?
::HtmlParser.parse_reply(decoded)
end
end
@@ -128,4 +129,15 @@ class MailPresenter < SimpleDelegator
rescue StandardError
''
end
def html_mail_body?
((mail.content_type || '').include? 'text/html') || @mail.html_part || @mail.html_part.content_type.include?('text/html')
end
# returns mail body if mail content_type is text/plain
def encoded_mail_body
return encode_to_unicode(@mail.body.decoded) if (@mail.content_type || '').include? 'text/plain'
''
end
end