diff --git a/lib/database/accounts.js b/lib/database/accounts.js index f270e5d7..5128e858 100644 --- a/lib/database/accounts.js +++ b/lib/database/accounts.js @@ -13,7 +13,7 @@ var blackHole = function () { }; * visually identical to existing names in certain fonts. */ function wildcardSimilarChars(name) { - return name.replace(/[Il1oO0]/g, "_"); + return name.replace(/_/g, "\\_").replace(/[Il1oO0]/g, "_"); } module.exports = { @@ -24,7 +24,8 @@ module.exports = { * Check if a username is taken */ isUsernameTaken: function (name, callback) { - db.query("SELECT name FROM `users` WHERE name LIKE ?", [wildcardSimilarChars(name)], + db.query("SELECT name FROM `users` WHERE name LIKE ? ESCAPE '\\\\'", + [wildcardSimilarChars(name)], function (err, rows) { if (err) { callback(err, true);