debug captcha: use safe alphabets only

Signed-off-by: hrj <harshad.rj@gmail.com>
This commit is contained in:
hrj 2021-04-13 13:07:44 +05:30
parent 41bdbc7fbf
commit b765399f68
2 changed files with 7 additions and 5 deletions

View File

@ -11,13 +11,15 @@ public class HelperFunctions {
RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
}
public static final String alphabets = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
public static final String numbers = "23456789";
public static final String safeAlphabets = "ABCDEFGHJKMNOPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
public static final String allAlphabets = safeAlphabets + "ILl";
public static final String safeNumbers = "23456789";
public static final String allNumbers = safeNumbers + "1";
public static final String specialCharacters = "$#%@&?";
public static final String allCharacters = alphabets + numbers + specialCharacters;
public static final String safeCharacters = safeAlphabets + safeNumbers + specialCharacters;
public static String randomString(final int n) {
return randomString(n, allCharacters);
return randomString(n, safeCharacters);
}
public static String randomString(final int n, final String characters) {

View File

@ -58,7 +58,7 @@ class DebugCaptcha extends ChallengeProvider {
}
def returnChallenge(): Challenge = {
val secret = HelperFunctions.randomString(6, HelperFunctions.alphabets)
val secret = HelperFunctions.randomString(6, HelperFunctions.safeAlphabets)
new Challenge(simpleText(secret), "image/png", secret.toLowerCase())
}
}