mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Do not add empty use/svg tags in ExcerptParser (#19969)
There was an issue where if hashtag-cooked HTML was sent to the ExcerptParser without the keep_svg option, we would end up with empty </use> and </svg> tags on the parts of the excerpt where the hashtag was, in this case when a post push notification was sent. Fixed this, and also added a way to only display a plaintext version of the hashtag for cases like this via PrettyText#excerpt.
This commit is contained in:
@@ -1209,6 +1209,22 @@ RSpec.describe PostAlerter do
|
||||
expect(JSON.parse(body)).to eq(payload)
|
||||
end
|
||||
|
||||
it "does not have invalid HTML in the excerpt when enable_experimental_hashtag_autocomplete is enabled" do
|
||||
SiteSetting.enable_experimental_hashtag_autocomplete = true
|
||||
Fabricate(:category, slug: "random")
|
||||
Jobs.run_immediately!
|
||||
body = nil
|
||||
|
||||
stub_request(:post, "https://site2.com/push").to_return do |request|
|
||||
body = request.body
|
||||
{ status: 200, body: "OK" }
|
||||
end
|
||||
create_post_with_alerts(user: user, raw: "this, @eviltrout, is a test with #random")
|
||||
expect(JSON.parse(body)["notifications"][0]["excerpt"]).to eq(
|
||||
"this, @eviltrout, is a test with #random",
|
||||
)
|
||||
end
|
||||
|
||||
context "with push subscriptions" do
|
||||
before do
|
||||
Fabricate(:push_subscription, user: evil_trout)
|
||||
|
||||
Reference in New Issue
Block a user