Skip to content

A platform for community discussion. Free, open, simple.

FIX: Escaped mentions in chat excerpts

Blake Erickson6dcb099547a2
diff --git a/plugins/chat/app/models/chat_message.rb b/plugins/chat/app/models/chat_message.rb
index 13039d6421d..be14d09e496 100644
--- a/plugins/chat/app/models/chat_message.rb
+++ b/plugins/chat/app/models/chat_message.rb
@@ -90,7 +90,7 @@ class ChatMessage < ActiveRecord::Base
return uploads.first.original_filename if cooked.blank? && uploads.present?
# this may return blank for some complex things like quotes, that is acceptable
- PrettyText.excerpt(cooked, max_length, { text_entities: true })
+ PrettyText.excerpt(message, max_length, { text_entities: true })
end
def cooked_for_excerpt
diff --git a/plugins/chat/spec/models/chat_message_spec.rb b/plugins/chat/spec/models/chat_message_spec.rb
index de1f70540a9..f12d2308e54 100644
--- a/plugins/chat/spec/models/chat_message_spec.rb
+++ b/plugins/chat/spec/models/chat_message_spec.rb
@@ -287,24 +287,6 @@ describe ChatMessage do
COOKED
)
expect(message.excerpt).to eq("https://twitter.com/EffinBirds/status/1518743508378697729")
- message =
- Fabricate.build(
- :chat_message,
- message:
- "wow check out these birbs https://twitter.com/EffinBirds/status/1518743508378697729",
- )
- expect(message.excerpt).to eq(
- "wow check out these birbs <a href=\"https://twitter.com/EffinBirds/status/1518743508378697729\" class=\"inline-onebox-loading\" rel=\"noopener nofollow ugc\">https://twitter.com/Effi...</a>",
- )
- end
-
- it "returns an empty string if PrettyText.excerpt returns empty string" do
- message = Fabricate(:chat_message, message: <<~MSG)
- [quote="martin, post:30, topic:3179, full:true"]
- This is a real **quote** topic with some *markdown* in it I can quote.
- [/quote]
- MSG
- expect(message.excerpt).to eq("")
end
it "excerpts upload file name if message is empty" do