Index: binaries/data/mods/public/gui/common/functions_utility.js =================================================================== --- binaries/data/mods/public/gui/common/functions_utility.js +++ binaries/data/mods/public/gui/common/functions_utility.js @@ -130,24 +130,6 @@ } } -// Filter out conflicting characters and limit the length of a given name. -// @param name Name to be filtered. -// @param stripUnicode Whether or not to remove unicode characters. -// @param stripSpaces Whether or not to remove whitespace. -function sanitizePlayerName(name, stripUnicode, stripSpaces) -{ - // We delete the '[', ']' characters (GUI tags) and delete the ',' characters (player name separators) by default. - var sanitizedName = name.replace(/[\[\],]/g, ""); - // Optionally strip unicode - if (stripUnicode) - sanitizedName = sanitizedName.replace(/[^\x20-\x7f]/g, ""); - // Optionally strip whitespace - if (stripSpaces) - sanitizedName = sanitizedName.replace(/\s/g, ""); - // Limit the length to 20 characters - return sanitizedName.substr(0,20); -} - function singleplayerName() { return Engine.ConfigDB_GetValue("user", "playername.singleplayer") || Engine.GetSystemUsername(); Index: binaries/data/mods/public/gui/lobby/prelobby.js =================================================================== --- binaries/data/mods/public/gui/lobby/prelobby.js +++ binaries/data/mods/public/gui/lobby/prelobby.js @@ -91,8 +91,8 @@ continueButton.enabled = false; feedback.caption = translate("Please enter your username"); } - // Check that they are using a valid username. - else if (username != sanitizePlayerName(username, true, true)) + + if (!username.match(/^[a-z0-9._-]*$/i) || username.length > 20); { continueButton.enabled = false; feedback.caption = translate("Usernames can't contain \\[, ], unicode, whitespace, or commas"); @@ -180,8 +180,8 @@ { Engine.PopGuiPage(); Engine.SwitchGuiPage("page_lobby.xml"); - Engine.ConfigDB_CreateValue("user", "playername.multiplayer", sanitizePlayerName(username, true, true)); - Engine.ConfigDB_WriteValueToFile("user", "playername.multiplayer", sanitizePlayerName(username, true, true), "config/user.cfg"); + Engine.ConfigDB_CreateValue("user", "playername.multiplayer", username); + Engine.ConfigDB_WriteValueToFile("user", "playername.multiplayer", username, "config/user.cfg"); Engine.ConfigDB_CreateValue("user", "lobby.login", username); Engine.ConfigDB_WriteValueToFile("user", "lobby.login", username, "config/user.cfg"); // We only store the encrypted password, so make sure to re-encrypt it if changed before saving.