2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-05 08:59:27 +08:00

FEATURE: escape HTML when cooking plaintext emails

This commit is contained in:
Gerhard Schlager 2017-11-15 16:39:29 +01:00
parent cef64e8f03
commit 9207dee69a
5 changed files with 201 additions and 47 deletions

View file

@ -38,6 +38,11 @@ module Email
attr_reader :mail
attr_reader :message_id
def self.formats
@formats ||= Enum.new(plaintext: 1,
markdown: 2)
end
def initialize(mail_string)
raise EmptyEmailError if mail_string.blank?
@staged_users = []
@ -236,9 +241,9 @@ module Email
end
if text.blank? || (SiteSetting.incoming_email_prefer_html && markdown.present?)
return [markdown, elided_markdown]
return [markdown, elided_markdown, Receiver::formats[:markdown]]
else
return [text, elided_text]
return [text, elided_text, Receiver::formats[:plaintext]]
end
end