diff --git a/app/models/emoji.rb b/app/models/emoji.rb index 33bc4657e49..89a1b5a2d4e 100644 --- a/app/models/emoji.rb +++ b/app/models/emoji.rb @@ -327,6 +327,6 @@ class Emoji end def self.sanitize_emoji_name(name) - name.gsub(/[^a-z0-9]+/i, "_").gsub(/_{2,}/, "_").downcase + name.gsub(/[^a-z0-9\+\-]+/i, "_").gsub(/_{2,}/, "_").downcase end end diff --git a/spec/lib/plugin/instance_spec.rb b/spec/lib/plugin/instance_spec.rb index 37e93b1cb4a..172c48d4893 100644 --- a/spec/lib/plugin/instance_spec.rb +++ b/spec/lib/plugin/instance_spec.rb @@ -706,9 +706,13 @@ TEXT it "sanitizes emojis' names" do Plugin::Instance.new.register_emoji("?", "/baz/bar.png", "baz") Plugin::Instance.new.register_emoji("?test?!!", "/foo/bar.png", "baz") + Plugin::Instance.new.register_emoji("+1", "/foo/bar.png", "baz") + Plugin::Instance.new.register_emoji("test!-1", "/foo/bar.png", "baz") expect(Emoji.custom.first.name).to eq("_") expect(Emoji.custom.second.name).to eq("_test_") + expect(Emoji.custom.third.name).to eq("+1") + expect(Emoji.custom.fourth.name).to eq("test_-1") end end