Skip to content

Commit

Permalink
排序属性orderBy参数限制长度
Browse files Browse the repository at this point in the history
  • Loading branch information
yangzongzhuan committed Jul 6, 2023
1 parent ad954da commit ee2fef0
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ public class SqlUtil
*/
public static String SQL_PATTERN = "[a-zA-Z0-9_\\ \\,\\.]+";

/**
* 限制orderBy最大长度
*/
private static final int ORDER_BY_MAX_LENGTH = 500;

/**
* 检查字符,防止注入绕过
*/
Expand All @@ -29,6 +34,10 @@ public static String escapeOrderBySql(String value)
{
throw new UtilException("参数不符合规范,不能进行查询");
}
if (StringUtils.length(value) > ORDER_BY_MAX_LENGTH)
{
throw new UtilException("参数已超过最大限制,不能进行查询");
}
return value;
}

Expand Down

0 comments on commit ee2fef0

Please sign in to comment.