diff --git a/app/lib/email_processor.rb b/app/lib/email_processor.rb index a387762b..ab7bc055 100644 --- a/app/lib/email_processor.rb +++ b/app/lib/email_processor.rb @@ -311,10 +311,14 @@ def clean_message(body) body&.gsub!(/$/, "")&.gsub!(/$/, "")&.gsub!(/^$\n/, "") # remove last unnecessary line break body&.gsub!(/--( \*)?$\z/, "") # remove gmail signature break body&.gsub!(/]*>.*?<\/style>/mi, '') # remove styles + body&.gsub!(/]*>.*?<\/xml>/mi, '') # remove xml + body&.gsub!(//m, '') # remove comments + body&.gsub!('', '') # remove comments body&.gsub!(/\z/, "")&.gsub!(/\z/, "")&.gsub!(/^$\n\z/, "") # remove last unnecessary line break body&.gsub!(/\z/, "")&.gsub!(/\z/, "")&.gsub!(/^$\n\z/, "") # remove last unnecessary line break body&.gsub!(/\z/, "")&.gsub!(/\z/, "")&.gsub!(/^$\n\z/, "") # remove last unnecessary line break body&.gsub!(/\z/, "")&.gsub!(/\z/, "")&.gsub!(/^$\n\z/, "") # remove last unnecessary line break + body&.gsub!(/\A(\s*|\s*

\s*<\/p>|\s*

\s*<\/div>|\s*\n|\s*\r\n)*/, '') # remove beginning line breaks body&.gsub!("p.MsoNormal,p.MsoNoSpacing{margin:0}", "") # remove outlook styles body = body&.strip @@ -360,6 +364,10 @@ def clean_html_version(html) html = html.presence || "" html = html.split("
\n--").first # strip out gmail signature html&.gsub!(/]*>.*?<\/style>/mi, '') # remove styles + html&.gsub!(/]*>.*?<\/xml>/mi, '') # remove xml + html.gsub!(//m, '') # remove comments + html.gsub!('', '') # remove comments + html&.gsub!(/\A/, "") # remove
from very beginning of html html&.gsub!(/
.+<\/div>/, "") # remove hidden divs / tracking pixels html&.gsub!(/src=\"cid\:\S+\"/, "src=\"\" style=\"display: none;\"") # remove attached images showing as broken inline images @@ -371,6 +379,7 @@ def clean_html_version(html) end html&.gsub!(/$/, "")&.gsub!(/$/, "")&.gsub!(/^$\n/, "") # remove last unnecessary line break + html&.gsub!(/\A(\s*|\s*

\s*<\/p>|\s*

\s*<\/div>|\s*\n|\s*\r\n)*/, '') to_utf8(html) end