Fix #461: MUC working with spaces etc. in room names

This commit is contained in:
Christoph 2015-09-03 16:13:01 +02:00
parent c9b0d4c86a
commit 19ef0f8c71
3 changed files with 7 additions and 6 deletions

View File

@ -2319,15 +2319,16 @@
else { $nick.removeClass('error'); } else { $nick.removeClass('error'); }
if (ev.type === 'click') { if (ev.type === 'click') {
name = $(ev.target).text();
jid = $(ev.target).attr('data-room-jid'); jid = $(ev.target).attr('data-room-jid');
} else { } else {
$name = this.$el.find('input.new-chatroom-name'); $name = this.$el.find('input.new-chatroom-name');
$server= this.$el.find('input.new-chatroom-server'); $server= this.$el.find('input.new-chatroom-server');
server = $server.val(); server = $server.val();
name = $name.val().trim().toLowerCase(); name = $name.val().trim();
$name.val(''); // Clear the input $name.val(''); // Clear the input
if (name && server) { if (name && server) {
jid = Strophe.escapeNode(name) + '@' + server; jid = Strophe.escapeNode(name.toLowerCase()) + '@' + server;
$name.removeClass('error'); $name.removeClass('error');
$server.removeClass('error'); $server.removeClass('error');
this.model.save({muc_domain: server}); this.model.save({muc_domain: server});
@ -2341,7 +2342,7 @@
chatroom = converse.chatboxviews.showChat({ chatroom = converse.chatboxviews.showChat({
'id': jid, 'id': jid,
'jid': jid, 'jid': jid,
'name': Strophe.unescapeNode(Strophe.getNodeFromJid(jid)), 'name': name || Strophe.unescapeNode(Strophe.getNodeFromJid(jid)),
'nick': nick, 'nick': nick,
'chatroom': true, 'chatroom': true,
'box_id' : b64_sha1(jid) 'box_id' : b64_sha1(jid)
@ -3009,7 +3010,7 @@
getRoomJIDAndNick: function (nick) { getRoomJIDAndNick: function (nick) {
nick = nick || this.model.get('nick'); nick = nick || this.model.get('nick');
var room = this.model.get('jid'); var room = this.model.get('jid');
var node = Strophe.escapeNode(Strophe.getNodeFromJid(room)); var node = Strophe.getNodeFromJid(room);
var domain = Strophe.getDomainFromJid(room); var domain = Strophe.getDomainFromJid(room);
return node + "@" + domain + (nick !== null ? "/" + nick : ""); return node + "@" + domain + (nick !== null ? "/" + nick : "");
}, },

View File

@ -5,7 +5,7 @@
<a class="close-chatbox-button icon-close"></a> <a class="close-chatbox-button icon-close"></a>
<a class="toggle-chatbox-button icon-minus"></a> <a class="toggle-chatbox-button icon-minus"></a>
<a class="configure-chatroom-button icon-wrench" style="display:none"></a> <a class="configure-chatroom-button icon-wrench" style="display:none"></a>
<div class="chat-title"> {{ name }} </div> <div class="chat-title"> {{ _.escape(name) }} </div>
<p class="chatroom-topic"><p/> <p class="chatroom-topic"><p/>
</div> </div>
<div class="chat-body"><span class="spinner centered"/></div> <div class="chat-body"><span class="spinner centered"/></div>

View File

@ -1,6 +1,6 @@
<dd class="available-chatroom"> <dd class="available-chatroom">
<a class="open-room" data-room-jid="{{jid}}" <a class="open-room" data-room-jid="{{jid}}"
title="{{open_title}}" href="#">{{name}}</a> title="{{open_title}}" href="#">{{_.escape(name)}}</a>
<a class="room-info icon-room-info" data-room-jid="{{jid}}" <a class="room-info icon-room-info" data-room-jid="{{jid}}"
title="{{info_title}}" href="#">&nbsp;</a> title="{{info_title}}" href="#">&nbsp;</a>
</dd> </dd>