Ban non-alnum characters at start of names

This commit is contained in:
Guangcong Luo 2014-05-20 01:58:04 -04:00
parent 762fdcc4fd
commit f7ea60fe25

View File

@ -571,13 +571,12 @@ var User = (function () {
Rooms.get(i, 'lobby').onUpdateIdentity(this);
}
};
var bannedNameStartChars = {'~':1, '&':1, '@':1, '%':1, '+':1, '-':1, '!':1, '?':1, '#':1, ' ':1, '{':1, '}':1};
User.prototype.filterName = function (name) {
if (Config.namefilter) {
name = Config.namefilter(name);
}
name = toName(name);
while (bannedNameStartChars[name.charAt(0)]) {
while (!/[A-Za-z0-9]/.test(name.charAt(0))) {
name = name.substr(1);
}
return name;