Kaynağa Gözat

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

RuoYi 5 yıl önce
ebeveyn
işleme
4a48702ccb

+ 4 - 3
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/sql/SqlUtil.java

@@ -1,5 +1,6 @@
1 1
 package com.ruoyi.common.core.utils.sql;
2 2
 
3
+import com.ruoyi.common.core.exception.BaseException;
3 4
 import com.ruoyi.common.core.utils.StringUtils;
4 5
 
5 6
 /**
@@ -10,9 +11,9 @@ import com.ruoyi.common.core.utils.StringUtils;
10 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 22
     {
22 23
         if (StringUtils.isNotEmpty(value) && !isValidOrderBySql(value))
23 24
         {
24
-            return StringUtils.EMPTY;
25
+            throw new BaseException("参数不符合规范,不能进行查询");
25 26
         }
26 27
         return value;
27 28
     }