mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 18:03:43 +08:00
FIX: ensure we never send elided content via email
This commit is contained in:
parent
6a5dad0b86
commit
3b06e5502b
|
@ -13,7 +13,7 @@ after_initialize do
|
|||
|
||||
Email::Styles.register_plugin_style do |fragment|
|
||||
# remove all elided content
|
||||
fragment.css("details.elided").each { |d| d.remove }
|
||||
fragment.css("details.elided").each(&:remove)
|
||||
|
||||
# replace all details with their summary in emails
|
||||
fragment.css("details").each do |details|
|
||||
|
@ -28,4 +28,8 @@ after_initialize do
|
|||
end
|
||||
end
|
||||
|
||||
on(:reduce_cooked) do |fragment|
|
||||
fragment.css("details.elided").each(&:remove)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -4,9 +4,6 @@ require 'pretty_text'
|
|||
describe PrettyText do
|
||||
|
||||
it "supports details tag" do
|
||||
cooked_html = "<details><summary>foo</summary>bar</details>"
|
||||
expect(PrettyText.cook("<details><summary>foo</summary>bar</details>")).to match_html(cooked_html)
|
||||
|
||||
cooked_html = <<~HTML
|
||||
<details>
|
||||
<summary>
|
||||
|
@ -14,7 +11,16 @@ describe PrettyText do
|
|||
<p>bar</p>
|
||||
</details>
|
||||
HTML
|
||||
expect(PrettyText.cook("[details=foo]\nbar\n[/details]")).to eq(cooked_html.strip)
|
||||
|
||||
expect(cooked_html).to match_html(cooked_html)
|
||||
expect(PrettyText.cook("[details=foo]\nbar\n[/details]")).to match_html(cooked_html)
|
||||
end
|
||||
|
||||
it "deletes elided content" do
|
||||
cooked_html = PrettyText.cook("Hello World\n\n<details class='elided'>42</details>")
|
||||
mail_html = PrettyText.cook("Hello World")
|
||||
|
||||
expect(PrettyText.format_for_email(cooked_html)).to match_html(mail_html)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user