A platform for community discussion. Free, open, simple.
FIX: supports html entities in chat (#34591)
Joffrey JAFFEUX17d6cb2111d7
diff --git a/plugins/chat/app/models/chat/message.rb b/plugins/chat/app/models/chat/message.rbindex 5b09e5cf442..529b9a4d562 100644--- a/plugins/chat/app/models/chat/message.rb+++ b/plugins/chat/app/models/chat/message.rb@@ -245,6 +245,7 @@ module Chatemphasisreplacementsescape+ entity]def self.cook(message, opts = {})diff --git a/plugins/chat/spec/lib/chat/core_pretty_text_spec.rb b/plugins/chat/spec/lib/chat/core_pretty_text_spec.rbindex 91edc7b54b9..6156b0b9a0f 100644--- a/plugins/chat/spec/lib/chat/core_pretty_text_spec.rb+++ b/plugins/chat/spec/lib/chat/core_pretty_text_spec.rb@@ -97,4 +97,16 @@ RSpec.describe PrettyText do"<div class=\"chat-transcript-messages\">\n<p>original message</p></div>",)end++ it "converts HTML entities" do+ cooked = PrettyText.cook("The micro sign: µ")+ expect(cooked).to include("The micro sign: µ")++ cooked = PrettyText.cook("Copyright © symbol")+ expect(cooked).to include("Copyright © symbol")++ # not converted for security reasons+ cooked = PrettyText.cook("Less than < and greater than >")+ expect(cooked).to include("Less than < and greater than >")+ endend