Skip to content

Commit

Permalink
FIX: prevent cross-contamination of emojis in multisites
Browse files Browse the repository at this point in the history
  • Loading branch information
ZogStriP committed Oct 30, 2015
1 parent 5e3da94 commit 7fbf902
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/assets/javascripts/discourse/lib/emoji/emoji.js.erb
Expand Up @@ -12,6 +12,11 @@ Discourse.Dialect.registerEmoji = function(code, url) {
extendedEmoji[code] = url;
};

// This method is used by PrettyText to reset custom emojis in multisites
Discourse.Dialect.resetEmoji = function() {
extendedEmoji = {};
};

Discourse.Emoji.list = function(){
var list = emoji.slice(0);
_.each(extendedEmoji, function(v,k){ list.push(k); });
Expand Down
2 changes: 2 additions & 0 deletions lib/pretty_text.rb
Expand Up @@ -189,6 +189,8 @@ def self.markdown(text, opts=nil)
end
end

# reset emojis (v8 context is shared amongst multisites)
context.eval("Discourse.Dialect.resetEmoji();")
# custom emojis
Emoji.custom.each do |emoji|
context.eval("Discourse.Dialect.registerEmoji('#{emoji.name}', '#{emoji.url}');")
Expand Down

0 comments on commit 7fbf902

Please sign in to comment.