Skip to content

Commit

Permalink
remove outlook styles
Browse files Browse the repository at this point in the history
  • Loading branch information
parterburn committed Apr 15, 2024
1 parent cbd4ecb commit 5c6d314
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/lib/email_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ def clean_message(body)
body&.gsub!(/<br\s*\/?>\z/, "")&.gsub!(/<br\s*\/?>\z/, "")&.gsub!(/^$\n\z/, "") # remove last unnecessary line break
body&.gsub!(/<br\s*\/?>\z/, "")&.gsub!(/<br\s*\/?>\z/, "")&.gsub!(/^$\n\z/, "") # remove last unnecessary line break
body&.gsub!(/<br\s*\/?>\z/, "")&.gsub!(/<br\s*\/?>\z/, "")&.gsub!(/^$\n\z/, "") # remove last unnecessary line break
body&.gsub!("p.MsoNormal,p.MsoNoSpacing{margin:0}", "") # remove outlook styles
body = body&.strip

return unless body.present?
Expand Down Expand Up @@ -354,6 +355,7 @@ def clean_html_version(html)
html&.gsub!(/\A<br\s*\/?>/, "") # remove <br> from very beginning of html
html&.gsub!(/<div style="display:none;border:0px;width:0px;height:0px;overflow:hidden;">.+<\/div>/, "") # remove hidden divs / tracking pixels
html&.gsub!(/src=\"cid\:\S+\"/, "src=\"\" style=\"display: none;\"") # remove attached images showing as broken inline images
html&.gsub!("p.MsoNormal,p.MsoNoSpacing{margin:0}", "") # remove outlook styles

empty_line_regex = /(<div>\n<div>\z)|(<br\s*\/?>\z)|(\n\z)/
while html&.match?(empty_line_regex)
Expand Down

0 comments on commit 5c6d314

Please sign in to comment.