正在显示
1 个修改的文件
包含
9 行增加
和
0 行删除
| @@ -21,6 +21,11 @@ public class SqlUtil | @@ -21,6 +21,11 @@ public class SqlUtil | ||
| 21 | public static String SQL_PATTERN = "[a-zA-Z0-9_\\ \\,\\.]+"; | 21 | public static String SQL_PATTERN = "[a-zA-Z0-9_\\ \\,\\.]+"; |
| 22 | 22 | ||
| 23 | /** | 23 | /** |
| 24 | + * 限制orderBy最大长度 | ||
| 25 | + */ | ||
| 26 | + private static final int ORDER_BY_MAX_LENGTH = 500; | ||
| 27 | + | ||
| 28 | + /** | ||
| 24 | * 检查字符,防止注入绕过 | 29 | * 检查字符,防止注入绕过 |
| 25 | */ | 30 | */ |
| 26 | public static String escapeOrderBySql(String value) | 31 | public static String escapeOrderBySql(String value) |
| @@ -29,6 +34,10 @@ public class SqlUtil | @@ -29,6 +34,10 @@ public class SqlUtil | ||
| 29 | { | 34 | { |
| 30 | throw new UtilException("参数不符合规范,不能进行查询"); | 35 | throw new UtilException("参数不符合规范,不能进行查询"); |
| 31 | } | 36 | } |
| 37 | + if (StringUtils.length(value) > ORDER_BY_MAX_LENGTH) | ||
| 38 | + { | ||
| 39 | + throw new UtilException("参数已超过最大限制,不能进行查询"); | ||
| 40 | + } | ||
| 32 | return value; | 41 | return value; |
| 33 | } | 42 | } |
| 34 | 43 |
-
请 注册 或 登录 后发表评论