FIX: do not show spoiler content in RSS (#14277)

FIX: do not show spoiler content in RSS (#14277)

This commit updates the RSS post content to use email formatting. Many plugins are using the reduce_cooked method to format content that is not displayed outside of Discourse application. Using email formatting also strips the secure media and various other things that is only meant for Discourse client side application.

diff --git a/app/views/list/list.rss.erb b/app/views/list/list.rss.erb
index 040ece9..9e3dfc8 100644
--- a/app/views/list/list.rss.erb
+++ b/app/views/list/list.rss.erb
@@ -18,7 +18,7 @@
           <category><%= topic.category.name %></category>
           <description><![CDATA[
             <%- if first_post = topic.ordered_posts.first %>
-            <%= first_post.cooked.html_safe %>
+            <%= PrettyText.format_for_email(first_post.cooked, first_post).html_safe %>
             <%- end %>
             <p><small><%= t 'rss_num_posts', count: topic.posts_count %> - <%= t 'rss_num_participants', count: topic.participant_count %></small></p>
             <p><%= link_to t('read_full_topic'), topic_url %></p>
diff --git a/app/views/posts/latest.rss.erb b/app/views/posts/latest.rss.erb
index 8f97eff..1d7443d 100644
--- a/app/views/posts/latest.rss.erb
+++ b/app/views/posts/latest.rss.erb
@@ -11,7 +11,7 @@
       <item>
         <title><%= post.topic.title %></title>
         <dc:creator><![CDATA[<%= "@#{post.user.username}#{" #{post.user.name}" if (post.user.name.present? && SiteSetting.enable_names?)}" -%>]]></dc:creator>
-        <description><![CDATA[ <%= post.cooked.html_safe %> ]]></description>
+        <description><![CDATA[ <%= PrettyText.format_for_email(post.cooked, post).html_safe %> ]]></description>
         <link><%= Discourse.base_url + post.url %></link>
         <pubDate><%= post.created_at.rfc2822 %></pubDate>
         <guid isPermaLink="false"><%= Discourse.current_hostname %>-post-<%= post.id %></guid>
diff --git a/app/views/topics/show.rss.erb b/app/views/topics/show.rss.erb
index 7da1470..bbb4989 100644
--- a/app/views/topics/show.rss.erb
+++ b/app/views/topics/show.rss.erb
@@ -21,7 +21,7 @@
           <% if post.hidden %>
             <%= t('flagging.user_must_edit').html_safe %>
           <% else %>
-            <%= post.cooked.html_safe %>
+            <%= PrettyText.format_for_email(post.cooked, post).html_safe %>
           <% end %>
           <p><%= link_to t('read_full_topic'), post_url %></p>
         ]]></description>

GitHub sha: 01341f33e3f16777767d0ad80008c52d4d44d941

This commit appears in #14277 which was approved by eviltrout. It was merged by techAPJ.

This commit has been mentioned on Discourse Meta. There might be relevant details there: