From 0a893d196e907a335cfec5d3d5b13e1f8ecd15ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Tue, 5 Jul 2022 02:06:31 +0000 Subject: [PATCH] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=E9=AD=94=E6=B3=95?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/common/filter/RepeatedlyRequestWrapper.java | 7 ++++--- .../src/main/java/com/ruoyi/common/filter/XssFilter.java | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java b/ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java index caacba6..ca822ed 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java @@ -10,6 +10,7 @@ import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; import com.ruoyi.common.utils.http.HttpHelper; +import com.ruoyi.common.constant.Constants; /** * 构建可重复读取inputStream的request @@ -23,10 +24,10 @@ public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper public RepeatedlyRequestWrapper(HttpServletRequest request, ServletResponse response) throws IOException { super(request); - request.setCharacterEncoding("UTF-8"); - response.setCharacterEncoding("UTF-8"); + request.setCharacterEncoding(Constants.UTF8); + response.setCharacterEncoding(Constants.UTF8); - body = HttpHelper.getBodyString(request).getBytes("UTF-8"); + body = HttpHelper.getBodyString(request).getBytes(Constants.UTF8); } @Override diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/filter/XssFilter.java b/ruoyi-common/src/main/java/com/ruoyi/common/filter/XssFilter.java index 703ce9a..23a76fe 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/filter/XssFilter.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/filter/XssFilter.java @@ -12,6 +12,7 @@ import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.enums.HttpMethod; /** * 防止XSS攻击的过滤器 @@ -59,7 +60,7 @@ public class XssFilter implements Filter String url = request.getServletPath(); String method = request.getMethod(); // GET DELETE 不过滤 - if (method == null || method.matches("GET") || method.matches("DELETE")) + if (method == null || HttpMethod.GET.matches(method) || HttpMethod.DELETE.matches(method)) { return true; }