|
@@ -59,9 +59,9 @@ public final class StringUtils {
|
|
/**
|
|
/**
|
|
* 字符串去除空白内容
|
|
* 字符串去除空白内容
|
|
*
|
|
*
|
|
- * <ul> <li>\n 回车</li> <li>\t 水平制表符</li> <li>\s 空格</li> <li>\r 换行</li> </ul>
|
|
|
|
|
|
+ * <ul> <li>'"<>&*+=#-; sql注入黑名单</li> <li>\n 回车</li> <li>\t 水平制表符</li> <li>\s 空格</li> <li>\r 换行</li> </ul>
|
|
*/
|
|
*/
|
|
- private static final Pattern REPLACE_BLANK = Pattern.compile("\\s*|\t|\r|\n");
|
|
|
|
|
|
+ private static final Pattern REPLACE_BLANK = Pattern.compile("'|\"|\\<|\\>|&|\\*|\\+|=|#|-|;|\\s*|\t|\r|\n");
|
|
|
|
|
|
/**
|
|
/**
|
|
* 判断字符串中是否全是空白字符
|
|
* 判断字符串中是否全是空白字符
|
|
@@ -594,10 +594,11 @@ public final class StringUtils {
|
|
public static String sqlInjectionReplaceBlank(String str) {
|
|
public static String sqlInjectionReplaceBlank(String str) {
|
|
if (SqlInjectionUtils.check(str)) {
|
|
if (SqlInjectionUtils.check(str)) {
|
|
/**
|
|
/**
|
|
- * 存在 SQL 注入,去除空白内容
|
|
|
|
|
|
+ * 过滤sql黑名单字符,存在 SQL 注入,去除空白内容
|
|
*/
|
|
*/
|
|
Matcher matcher = REPLACE_BLANK.matcher(str);
|
|
Matcher matcher = REPLACE_BLANK.matcher(str);
|
|
- return matcher.replaceAll("");
|
|
|
|
|
|
+ str = matcher.replaceAll("");
|
|
|
|
+
|
|
}
|
|
}
|
|
return str;
|
|
return str;
|
|
}
|
|
}
|