mirror of https://github.com/calzoneman/sync.git
Fix underscore escaping for similar chars check
This commit is contained in:
parent
06347d6c25
commit
817e7ceb84
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue