Explorar o código

修复AuthFilter白名单过滤匹配不精准

DokiYoloo %!s(int64=5) %!d(string=hai) anos
pai
achega
48cf4250b4

+ 6 - 2
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/StringUtils.java

@@ -477,10 +477,14 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
477
 
477
 
478
             // 匹配前缀Pattern
478
             // 匹配前缀Pattern
479
             result = remainingURI.contains(prefixPattern);
479
             result = remainingURI.contains(prefixPattern);
480
-            // 已经没有星号,直接返回
480
+            // 已经没有星号,判断长度是否符合,并返回
481
             if (formerStarOffset == -1)
481
             if (formerStarOffset == -1)
482
             {
482
             {
483
-                return result;
483
+                //清洗请求路径
484
+                if (remainingURI.endsWith("/")) {
485
+                    remainingURI = remainingURI.substring(0, remainingURI.length() - 1);
486
+                }
487
+                return remainingURI.length() == prefixPattern.length();
484
             }
488
             }
485
 
489
 
486
             // 匹配失败,直接返回
490
             // 匹配失败,直接返回