Skip to content

Commit db0a2d0

Browse files
committed
Server防SQL注入:校验@Schema
1 parent 1b418e9 commit db0a2d0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

APIJSON-Java-Server/APIJSONLibrary/src/main/java/zuo/biao/apijson/server/AbstractSQLConfig.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,12 @@ public String getSchema() {
177177
}
178178
@Override
179179
public AbstractSQLConfig setSchema(String schema) {
180+
if (schema != null) {
181+
String s = schema.startsWith("`") && schema.endsWith("`") ? schema.substring(1, schema.length() - 1) : schema;
182+
if (StringUtil.isName(s) == false) {
183+
throw new IllegalArgumentException("@schema:value 中value必须是1个单词!");
184+
}
185+
}
180186
this.schema = schema;
181187
return this;
182188
}
@@ -203,7 +209,7 @@ public String getTablePath() {
203209
return getSchema() + "." + getSQLTable();
204210
}
205211
@Override
206-
public AbstractSQLConfig setTable(String table) {
212+
public AbstractSQLConfig setTable(String table) { //Table已经在Parser中校验,所以这里不用防SQL注入
207213
this.table = table;
208214
return this;
209215
}

0 commit comments

Comments
 (0)