作者 RuoYi

检查字符支持小数点&降级改成异常提醒

1 package com.ruoyi.common.utils.sql; 1 package com.ruoyi.common.utils.sql;
2 2
  3 +import com.ruoyi.common.exception.BaseException;
3 import com.ruoyi.common.utils.StringUtils; 4 import com.ruoyi.common.utils.StringUtils;
4 5
5 /** 6 /**
@@ -10,9 +11,9 @@ import com.ruoyi.common.utils.StringUtils; @@ -10,9 +11,9 @@ import com.ruoyi.common.utils.StringUtils;
10 public class SqlUtil 11 public class SqlUtil
11 { 12 {
12 /** 13 /**
13 - * 仅支持字母、数字、下划线、空格、逗号(支持多个字段排序) 14 + * 仅支持字母、数字、下划线、空格、逗号、小数点(支持多个字段排序)
14 */ 15 */
15 - public static String SQL_PATTERN = "[a-zA-Z0-9_\\ \\,]+"; 16 + public static String SQL_PATTERN = "[a-zA-Z0-9_\\ \\,\\.]+";
16 17
17 /** 18 /**
18 * 检查字符,防止注入绕过 19 * 检查字符,防止注入绕过
@@ -21,7 +22,7 @@ public class SqlUtil @@ -21,7 +22,7 @@ public class SqlUtil
21 { 22 {
22 if (StringUtils.isNotEmpty(value) && !isValidOrderBySql(value)) 23 if (StringUtils.isNotEmpty(value) && !isValidOrderBySql(value))
23 { 24 {
24 - return StringUtils.EMPTY; 25 + throw new BaseException("参数不符合规范,不能进行查询");
25 } 26 }
26 return value; 27 return value;
27 } 28 }