Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

escaping querying with IN clause #12720 #13327

Merged
merged 9 commits into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
modify
Signed-off-by: Jack Lu <dbqp99@msn.com>
  • Loading branch information
jacko9et committed Jul 20, 2020
commit 84759c099333248aa2632f70e06cfca8ea5a32b0
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ private String generateInQuery(@NonNull Criteria criteria, @NonNull List<Pair<St
}

final Collection<Object> values = (Collection<Object>) criteria.getSubjectValues().get(0);

final StringBuilder builder = new StringBuilder();
int index = 0;
int index = 0;
Iterator<Object> iterator = values.iterator();
while (iterator.hasNext()) {
Object o = iterator.next();
Expand All @@ -148,7 +148,7 @@ private String generateInQuery(@NonNull Criteria criteria, @NonNull List<Pair<St
builder.append(",@").append(key);
}
parameters.add(Pair.with(key, o));
index ++;
index++;
} else {
throw new IllegalQueryException("IN keyword Range only support Number and String type.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ public void testSqlInjection() {
assertProjectListEquals(projects, Arrays.asList(PROJECT_0, PROJECT_1, PROJECT_4));
projects = this.repository.findAllByHasReleasedIn(Collections.singleton(false));
assertProjectListEquals(projects, Arrays.asList(PROJECT_4));
projects = this.repository.findAllByNameIn(Collections.singleton("sql) or (r.firstName <> ''"));
projects = this.repository.findAllByNameIn(Collections.singleton("sql) or (r.name <> ''"));
assertTrue(projects.isEmpty());
}
}