diff --git a/converse.js b/converse.js
index c50e850d3..b80a5aca0 100644
--- a/converse.js
+++ b/converse.js
@@ -60,6 +60,7 @@
if (this.length > 0) {
this.each(function(i, obj) {
var text = $(obj).html();
+ text = text.replace(/>:\)/g, '');
text = text.replace(/:\)/g, '');
text = text.replace(/:\-\)/g, '');
text = text.replace(/;\)/g, '');
@@ -71,7 +72,6 @@
text = text.replace(/:p/g, '');
text = text.replace(/:\-p/g, '');
text = text.replace(/8\)/g, '');
- text = text.replace(/>:\)/g, '');
text = text.replace(/:S/g, '');
text = text.replace(/:\\/g, '');
text = text.replace(/:\/ /g, '');
@@ -82,7 +82,7 @@
text = text.replace(/:\-O/g, '');
text = text.replace(/\=\-O/g, '');
text = text.replace(/\(\^.\^\)b/g, '');
- text = text.replace(/<3/g, '');
+ text = text.replace(/<3/g, '');
$(obj).html(text);
});
}
diff --git a/spec/chatbox.js b/spec/chatbox.js
index c63667aed..a355f6283 100644
--- a/spec/chatbox.js
+++ b/spec/chatbox.js
@@ -626,6 +626,30 @@
expect(msg.html()).toEqual('This message contains a hyperlink: www.opkode.com');
}, converse));
+ it("should display emoticons correctly", $.proxy(function () {
+ var contact_jid = mock.cur_names[0].replace(' ','.').toLowerCase() + '@localhost';
+ utils.openChatBoxFor(contact_jid);
+ var view = this.chatboxviews.get(contact_jid);
+ var messages = [':)', ';)', ':D', ':P', '8)', '>:)', ':S', ':\\', '>:(', ':(', ':O', '(^.^)b', '<3'];
+ var emoticons = [
+ '', '',
+ '', '',
+ '', '',
+ '', '',
+ '', '',
+ '', '',
+ ''
+ ];
+ spyOn(view, 'sendMessage').andCallThrough();
+ for (var i = 0; i < messages.length; i++) {
+ var message = messages[i];
+ utils.sendMessage(view, message);
+ expect(view.sendMessage).toHaveBeenCalled();
+ var msg = view.$el.find('.chat-content').find('.chat-message').last().find('.chat-message-content');
+ expect(msg.html()).toEqual(emoticons[i]);
+ }
+ }, converse));
+
it("will have properly escaped URLs", $.proxy(function () {
var contact_jid = mock.cur_names[0].replace(' ','.').toLowerCase() + '@localhost';
utils.openChatBoxFor(contact_jid);