Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
RuoYi Vue
Commits
1ffb6379
Commit
1ffb6379
authored
Jul 06, 2023
by
RuoYi
Browse files
排序属性orderBy参数限制长度
parent
4d5c204b
Changes
1
Hide whitespace changes
Inline
Side-by-side
ruoyi-common/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java
View file @
1ffb6379
...
...
@@ -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
;
/**
* 检查字符,防止注入绕过
*/
...
...
@@ -29,6 +34,10 @@ public class SqlUtil
{
throw
new
UtilException
(
"参数不符合规范,不能进行查询"
);
}
if
(
StringUtils
.
length
(
value
)
>
ORDER_BY_MAX_LENGTH
)
{
throw
new
UtilException
(
"参数已超过最大限制,不能进行查询"
);
}
return
value
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment