FIX: proper details / summary excerpt (#30229)

It doesn't make much sense to have the content of a `<details>` in an excerpt so I replaced them with "▶ summary" instead.

That way, they can't be (ab)used in user cards for example.

Reference - https://meta.discourse.org/t/335094
This commit is contained in:
Régis Hanol
2024-12-12 09:09:49 +01:00
committed by GitHub
parent 7c00c52c36
commit 44cabc3569
3 changed files with 13 additions and 78 deletions

View File

@ -923,16 +923,10 @@ RSpec.describe PrettyText do
).to eq("![car](http://cnn.com/a.gif)")
end
it "should keep details if too long" do
it "replaces details / summary with the summary" do
expect(
PrettyText.excerpt("<details><summary>expand</summary><p>hello</p></details>", 6),
).to match_html "<details class='disabled'><summary>expand</summary></details>"
end
it "doesn't disable details if short enough" do
expect(
PrettyText.excerpt("<details><summary>expand</summary><p>hello</p></details>", 60),
).to match_html "<details><summary>expand</summary>hello</details>"
).to match_html "▶ expand"
end
it "should remove meta information" do