From 5be7a2dad4a3aab55cda43a92a88d39e21011271 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Wed, 10 May 2017 14:01:26 -0400 Subject: [PATCH] FIX: invalid html in notification emails when template has been customized --- app/mailers/user_notifications.rb | 4 +--- lib/email/sender.rb | 2 -- lib/email/styles.rb | 5 +---- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/app/mailers/user_notifications.rb b/app/mailers/user_notifications.rb index d96d0ec8074..44d1cc7bd24 100644 --- a/app/mailers/user_notifications.rb +++ b/app/mailers/user_notifications.rb @@ -252,12 +252,10 @@ class UserNotifications < ActionMailer::Base end def email_post_markdown(post, add_posted_by=false) - result = "[email-indent]\n" - result << "#{post.raw}\n\n" + result = "#{post.raw}\n\n" if add_posted_by result << "#{I18n.t('user_notifications.posted_by', username: post.username, post_date: post.created_at.strftime("%m/%d/%Y"))}\n\n" end - result << "[/email-indent]\n" result end diff --git a/lib/email/sender.rb b/lib/email/sender.rb index db167a12dd7..61c5fc16854 100644 --- a/lib/email/sender.rb +++ b/lib/email/sender.rb @@ -51,8 +51,6 @@ module Email end end - @message.parts[0].body = @message.parts[0].body.to_s.gsub(/\[\/?email-indent\]/, '') - # Fix relative (ie upload) HTML links in markdown which do not work well in plain text emails. # These are the links we add when a user uploads a file or image. # Ideally we would parse general markdown into plain text, but that is almost an intractable problem. diff --git a/lib/email/styles.rb b/lib/email/styles.rb index efe8502abd3..9dd34e5da49 100644 --- a/lib/email/styles.rb +++ b/lib/email/styles.rb @@ -186,10 +186,7 @@ module Email def to_html strip_classes_and_ids replace_relative_urls - @fragment.to_html.tap do |result| - result.gsub!(/\[email-indent\]/, "
") - result.gsub!(/\[\/email-indent\]/, "
") - end + @fragment.to_html end def strip_avatars_and_emojis