A platform for community discussion. Free, open, simple.
FIX: Fixed custom emoji circumventing "max emojis in topic title" set⦠(#7116)
Tim Lange3ff0800e5093
diff --git a/lib/pretty_text.rb b/lib/pretty_text.rbindex e3a89fe4611..d4d8ce56f87 100644--- a/lib/pretty_text.rb+++ b/lib/pretty_text.rb@@ -230,10 +230,11 @@ module PrettyTextreturn title unless SiteSetting.enable_emoji?set = SiteSetting.emoji_set.inspect+ custom = Emoji.custom.map { |e| [e.name, e.url] }.to_h.to_jsonprotect dov8.eval(<<~JS)__paths = #{paths_json};- __performEmojiUnescape(#{title.inspect}, { getURL: __getURL, emojiSet: #{set} });+ __performEmojiUnescape(#{title.inspect}, { getURL: __getURL, emojiSet: #{set}, customEmoji: #{custom} });JSendenddiff --git a/spec/components/validators/max_emojis_validator_spec.rb b/spec/components/validators/max_emojis_validator_spec.rbindex 671caaea999..1242a32a4e8 100644--- a/spec/components/validators/max_emojis_validator_spec.rb+++ b/spec/components/validators/max_emojis_validator_spec.rb@@ -14,7 +14,9 @@ describe MaxEmojisValidator doshared_examples "validating any topic title" doit 'adds an error when emoji count is greater than SiteSetting.max_emojis_in_title' doSiteSetting.max_emojis_in_title = 3- record.title = 'π§ Lots of emojis here π :joy: :)'+ CustomEmoji.create!(name: 'trout', upload: Fabricate(:upload))+ Emoji.clear_cache+ record.title = 'π§ Lots of emojis here π :trout: :)'validateexpect(record.errors[:title][0]).to eq(I18n.t("errors.messages.max_emojis", max_emojis_count: 3))