Commit 358985c9 authored by JC Brand's avatar JC Brand

Bugfix. Allow spaces and weird chars in room names.

parent 5a56fcc6
...@@ -467,6 +467,7 @@ xmppchat.ContactsPanel = Backbone.View.extend({ ...@@ -467,6 +467,7 @@ xmppchat.ContactsPanel = Backbone.View.extend({
subscribeToContact: function (ev) { subscribeToContact: function (ev) {
ev.preventDefault(); ev.preventDefault();
// FIXME: Need to escape username
var jid = $(ev.target).attr('data-recipient'); var jid = $(ev.target).attr('data-recipient');
xmppchat.connection.roster.add(jid, '', [], function (iq) { xmppchat.connection.roster.add(jid, '', [], function (iq) {
// XXX: We can set the name here!!! // XXX: We can set the name here!!!
...@@ -507,7 +508,7 @@ xmppchat.RoomsPanel = Backbone.View.extend({ ...@@ -507,7 +508,7 @@ xmppchat.RoomsPanel = Backbone.View.extend({
this.$el.find('#available-chatrooms dt').hide(); this.$el.find('#available-chatrooms dt').hide();
} }
for (var i=0; i<rooms.length; i++) { for (var i=0; i<rooms.length; i++) {
name = $(rooms[i]).attr('name'); name = Strophe.unescapeNode($(rooms[i]).attr('name'));
jid = $(rooms[i]).attr('jid'); jid = $(rooms[i]).attr('jid');
this.$el.find('#available-chatrooms').append(this.room_template({'name':name, 'jid':jid})); this.$el.find('#available-chatrooms').append(this.room_template({'name':name, 'jid':jid}));
} }
...@@ -521,9 +522,12 @@ xmppchat.RoomsPanel = Backbone.View.extend({ ...@@ -521,9 +522,12 @@ xmppchat.RoomsPanel = Backbone.View.extend({
if (ev.type === 'click') { if (ev.type === 'click') {
jid = $(ev.target).attr('room-jid'); jid = $(ev.target).attr('room-jid');
} else { } else {
// FIXME: Hardcoded name = _.str.strip($(ev.target).find('input.new-chatroom-name').val()).toLowerCase();
name = $(ev.target).find('input.new-chatroom-name').val(); if (name) {
jid = name + '@' + xmppchat.connection.muc_domain; jid = Strophe.escapeNode(name) + '@' + xmppchat.connection.muc_domain;
} else {
return;
}
} }
xmppchat.chatboxesview.openChat(jid); xmppchat.chatboxesview.openChat(jid);
} }
...@@ -566,8 +570,8 @@ xmppchat.ChatRoom = xmppchat.ChatBox.extend({ ...@@ -566,8 +570,8 @@ xmppchat.ChatRoom = xmppchat.ChatBox.extend({
var nick = Strophe.getNodeFromJid(xmppchat.connection.jid); var nick = Strophe.getNodeFromJid(xmppchat.connection.jid);
this.set({ this.set({
'id': jid, 'id': jid,
'name': Strophe.getNodeFromJid(jid), 'name': Strophe.unescapeNode(Strophe.getNodeFromJid(jid)),
'nick': Strophe.getNodeFromJid(xmppchat.connection.jid), 'nick': Strophe.unescapeNode(Strophe.getNodeFromJid(xmppchat.connection.jid)),
'jid': jid, 'jid': jid,
'box_id' : this.hash(jid) 'box_id' : this.hash(jid)
}, {'silent': true}); }, {'silent': true});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment