mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 09:26:54 -06:00
FIX: do not treat :: as a valid emoji
This commit is contained in:
parent
057fa049e6
commit
ce1994beea
@ -1,7 +1,7 @@
|
||||
class MaxEmojisValidator < ActiveModel::EachValidator
|
||||
|
||||
def validate_each(record, attribute, value)
|
||||
if Emoji.unicode_unescape(value).scan(/:([\w\-+]*(?::t\d)?):/).size > SiteSetting.max_emojis_in_title
|
||||
if Emoji.unicode_unescape(value).scan(/:([\w\-+]+(?::t\d)?):/).size > SiteSetting.max_emojis_in_title
|
||||
record.errors.add(
|
||||
attribute, :max_emojis,
|
||||
max_emojis_count: SiteSetting.max_emojis_in_title
|
||||
|
@ -17,6 +17,10 @@ describe MaxEmojisValidator do
|
||||
record.title = '🧐 Lots of emojis here 🎃 :joy: :sunglasses:'
|
||||
validate
|
||||
expect(record.errors[:title][0]).to eq(I18n.t("errors.messages.max_emojis", max_emojis_count: 3))
|
||||
|
||||
record.title = ':joy: :blush: :smile: is not only about emojis: Happyness::start()'
|
||||
validate
|
||||
expect(record.valid?).to be true
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user