FIX: Fixed custom emoji circumventing "max emojis in topic title" set… (#7116)
This commit is contained in:
parent
0a9a11094d
commit
3ff0800e50
|
@ -230,10 +230,11 @@ module PrettyText
|
||||||
return title unless SiteSetting.enable_emoji?
|
return title unless SiteSetting.enable_emoji?
|
||||||
|
|
||||||
set = SiteSetting.emoji_set.inspect
|
set = SiteSetting.emoji_set.inspect
|
||||||
|
custom = Emoji.custom.map { |e| [e.name, e.url] }.to_h.to_json
|
||||||
protect do
|
protect do
|
||||||
v8.eval(<<~JS)
|
v8.eval(<<~JS)
|
||||||
__paths = #{paths_json};
|
__paths = #{paths_json};
|
||||||
__performEmojiUnescape(#{title.inspect}, { getURL: __getURL, emojiSet: #{set} });
|
__performEmojiUnescape(#{title.inspect}, { getURL: __getURL, emojiSet: #{set}, customEmoji: #{custom} });
|
||||||
JS
|
JS
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,9 @@ describe MaxEmojisValidator do
|
||||||
shared_examples "validating any topic title" do
|
shared_examples "validating any topic title" do
|
||||||
it 'adds an error when emoji count is greater than SiteSetting.max_emojis_in_title' do
|
it 'adds an error when emoji count is greater than SiteSetting.max_emojis_in_title' do
|
||||||
SiteSetting.max_emojis_in_title = 3
|
SiteSetting.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: :)'
|
||||||
validate
|
validate
|
||||||
expect(record.errors[:title][0]).to eq(I18n.t("errors.messages.max_emojis", max_emojis_count: 3))
|
expect(record.errors[:title][0]).to eq(I18n.t("errors.messages.max_emojis", max_emojis_count: 3))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue