diff --git a/app/mailers/subscription_mailer.rb b/app/mailers/subscription_mailer.rb index 6261e13bf..19437485d 100644 --- a/app/mailers/subscription_mailer.rb +++ b/app/mailers/subscription_mailer.rb @@ -1,4 +1,5 @@ class SubscriptionMailer < ApplicationMailer + helper PostsHelper helper UsersHelper def subscription diff --git a/app/views/subscription_mailer/subscription.html.erb b/app/views/subscription_mailer/subscription.html.erb index e1724b5d0..f2899d5f0 100644 --- a/app/views/subscription_mailer/subscription.html.erb +++ b/app/views/subscription_mailer/subscription.html.erb @@ -15,8 +15,7 @@ <%= link_to question.title, post_url(question, host: @subscription.community.host) %>
- <%= question.body.first(150).gsub(/<\/?[^>]+>/, '') %> - <%= question.body.length > 150 ? '...' : '' %> + <%= sanitize(strip_tags(question.body).truncate(150), scrubber: scrubber) %>
— <%= user_link question.user, { host: @subscription.community.host } %>
diff --git a/test/fixtures/posts.yml b/test/fixtures/posts.yml
index 63a1dee77..e2e59fb6d 100644
--- a/test/fixtures/posts.yml
+++ b/test/fixtures/posts.yml
@@ -590,3 +590,17 @@ without_new_thread_followers:
community: sample
category: main
license: cc_by_sa
+
+with_sanitized_html:
+ post_type: question
+ title: This post contains HTML in body that is sanitized away
+ body: |
+ This is the body of the post used to test HTML sanitization
+ oops
+ body_markdown: |
+
+ This is the body of the post used to test HTML sanitization
+ oops
+