feat: 提交项目代码
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package com.adc.da.xss;
|
||||
|
||||
import com.adc.da.exception.AdcDaBaseException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class SQLFilter {
|
||||
|
||||
|
||||
public static String sqlInject(String str) {
|
||||
if (StringUtils.isBlank(str)) {
|
||||
return null;
|
||||
} else {
|
||||
String checkStr= str;
|
||||
checkStr = StringUtils.replace(checkStr, "\\", "");
|
||||
checkStr = checkStr.toLowerCase();
|
||||
String[] keywords = new String[]{"master", "truncate", "insert", "select", "delete", "update", "declare", "alter", "drop"};
|
||||
String[] arr$ = keywords;
|
||||
int len$ = keywords.length;
|
||||
|
||||
for(int i$ = 0; i$ < len$; ++i$) {
|
||||
String keyword = arr$[i$];
|
||||
if (checkStr.indexOf(keyword) != -1) {
|
||||
throw new AdcDaBaseException("包含非法字符");
|
||||
}
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user