Remove \ character from password generation to avoid confusions

This commit is contained in:
Gregory Soutade 2015-12-04 17:03:12 +01:00
parent 6604fbb6e1
commit 487283626f

View File

@ -63,6 +63,8 @@ function generate_random(size, only_ascii)
else else
symbols = new Array(1, 255); symbols = new Array(1, 255);
forbidden = new Array('\\');
var res = ""; var res = "";
while (res.length < size) while (res.length < size)
{ {
@ -71,7 +73,18 @@ function generate_random(size, only_ascii)
r = Math.round(Math.random()*diff); r = Math.round(Math.random()*diff);
if (isNaN(r+symbols[a])) if (isNaN(r+symbols[a]))
continue; continue;
res += String.fromCharCode(r + symbols[a]); character = String.fromCharCode(r + symbols[a]);
forbid = false;
for (var j=0; j<forbidden.length; j++)
{
if (character == forbidden[j])
{
forbid = true;
break;
}
}
if (forbid) continue;
res += character;
} }
return res; return res;