Skip to content
Snippets Groups Projects
Commit 2636e049 authored by Manuel Spuhler's avatar Manuel Spuhler
Browse files

Simple Regex against SQL injection

parent da9203e5
No related branches found
No related tags found
No related merge requests found
......@@ -83,9 +83,13 @@ public class RequestsApi {
private List<String> extractVarCodes(JsonObject q, String field) {
List<String> codes = new LinkedList<>();
JsonArray elements = q.getAsJsonArray(field) != null ? q.getAsJsonArray(field) : new JsonArray();
Pattern p = Pattern.compile("\\w+");
for (JsonElement var : elements) {
String varCode = var.getAsJsonObject().get("code").getAsString();
codes.add(varCode);
Boolean isValidString = p.matcher(varCode).matches();
if (isValidString) {
codes.add(varCode);
}
}
return codes;
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment