mirror of https://github.com/calzoneman/sync.git
Fix bad channel names
This commit is contained in:
parent
090eaa37c2
commit
6042c510e1
3
user.js
3
user.js
|
@ -28,6 +28,7 @@ var User = function(socket, ip) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Set up socket callbacks
|
// Set up socket callbacks
|
||||||
User.prototype.initCallbacks = function() {
|
User.prototype.initCallbacks = function() {
|
||||||
// What a shame
|
// What a shame
|
||||||
|
@ -37,6 +38,8 @@ User.prototype.initCallbacks = function() {
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
this.socket.on('joinChannel', function(data) {
|
this.socket.on('joinChannel', function(data) {
|
||||||
|
if(!data.name.match(/[a-zA-Z0-9]+/))
|
||||||
|
return;
|
||||||
// Channel already loaded
|
// Channel already loaded
|
||||||
if(data.name in Server.channels) {
|
if(data.name in Server.channels) {
|
||||||
this.channel = Server.channels[data.name];
|
this.channel = Server.channels[data.name];
|
||||||
|
|
|
@ -61,6 +61,12 @@ if(params['channel'] == undefined) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else if(!params['channel'].match(/[a-zA-Z0-9]+/)) {
|
||||||
|
$('<div/>').addClass('alert alert-error')
|
||||||
|
.insertAfter($('.row')[0])[0]
|
||||||
|
.innerHTML = "<h3>Invalid Channel Name</h3><p>Channel names must conain only numbers and letters</p>";
|
||||||
|
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
socket.emit('joinChannel', {
|
socket.emit('joinChannel', {
|
||||||
name: params['channel']
|
name: params['channel']
|
||||||
|
|
Loading…
Reference in New Issue