Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
karussell committed Nov 13, 2024
1 parent 5f57655 commit 1b03f81
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,18 @@ void checkInvalidParameter(boolean reverse, String query, String point) {
if (query == null || query.trim().isEmpty()) {
throw new BadRequestException("q cannot be empty");
}
if (isInvalidString(query, "{}[]")) {
if (!isValid(query, "{}[]")) {
throw new BadRequestException("q contains invalid characters like {}[]");
}
}
}

public static boolean isInvalidString(String input, String allowedSpecialChars) {
public static boolean isValid(String input, String allowedSpecialChars) {
for (int i = 0; i < input.length(); i++) {
char c = input.charAt(i);
if (Character.isDigit(c))
continue;
if (!Character.isLetter(c) && allowedSpecialChars.indexOf(c) == -1)
return true;
if (allowedSpecialChars.indexOf(input.charAt(i)) >= 0)
return false;
}
return false;
return true;
}

String getLocaleFromParameter(String locale) {
Expand Down

0 comments on commit 1b03f81

Please sign in to comment.