Fix underscore escaping for similar chars check

This commit is contained in:
calzoneman 2015-07-20 19:07:58 -07:00
parent 06347d6c25
commit 817e7ceb84

View file

@ -13,7 +13,7 @@ var blackHole = function () { };
* visually identical to existing names in certain fonts. * visually identical to existing names in certain fonts.
*/ */
function wildcardSimilarChars(name) { function wildcardSimilarChars(name) {
return name.replace(/[Il1oO0]/g, "_"); return name.replace(/_/g, "\\_").replace(/[Il1oO0]/g, "_");
} }
module.exports = { module.exports = {
@ -24,7 +24,8 @@ module.exports = {
* Check if a username is taken * Check if a username is taken
*/ */
isUsernameTaken: function (name, callback) { 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) { function (err, rows) {
if (err) { if (err) {
callback(err, true); callback(err, true);