Skip to content

Commit 067eddb

Browse files
committed
Java:MultiDataSource 中 SQLAuto: 强校验 SQL 从 args: [] 中找值来校验 LIMIT limit, offset 范围
1 parent 09b3017 commit 067eddb

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/java/apijson/boot/DemoController.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2523,7 +2523,8 @@ public String execute(@RequestBody String request, HttpSession session) {
25232523
for (int i = 0; i < arr.length; i++) {
25242524
String as = arr[i];
25252525
if ("?".endsWith(as)) {
2526-
continue; // FIXME 不知道在第几个 as = arg.getString();
2526+
int j = arg == null ? -1 : arg.size() - (arr.length - i);
2527+
as = j < 0 || j > arg.size() ? null : arg.getString(j);
25272528
}
25282529

25292530
try {
@@ -2532,7 +2533,7 @@ public String execute(@RequestBody String request, HttpSession session) {
25322533
throw new IllegalArgumentException("SQL LIMIT " + s + " 超出范围 1~" + maxCount + " !");
25332534
}
25342535
} catch (Throwable e) {
2535-
throw new IllegalArgumentException("SQL LIMIT " + s + " 不合法!" + e.getMessage(), e);
2536+
throw new IllegalArgumentException("SQL LIMIT " + s + " 不合法! " + e.getMessage(), e);
25362537
}
25372538
}
25382539
}

0 commit comments

Comments
 (0)