From 56050aa6501f3d9d2f79a2c40a28815878ac56ee Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期四, 24 十一月 2022 15:14:47 +0800
Subject: [PATCH] update 同步 ruoyi 相关提交 * fix 修复Log注解GET请求记录不到参数问题 * fix 修复某些特性的环境生成代码变乱码TXT文件问题 * update 消除Vue3控制台出现的警告信息 * fix 开启TopNav没有子菜单隐藏侧边栏 * fix 修复回显数据字典数组异常问题(I60UYQ) * update 忽略不必要的属性数据返回

---
 ruoyi-common/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java |   56 +++++++++++++++++++++++---------------------------------
 1 files changed, 23 insertions(+), 33 deletions(-)

diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java b/ruoyi-common/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java
index 700a88d..3646f1f 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java
@@ -1,6 +1,7 @@
 package com.ruoyi.common.filter;
 
 import cn.hutool.core.io.IoUtil;
+import cn.hutool.core.util.StrUtil;
 import cn.hutool.http.HtmlUtil;
 import com.ruoyi.common.utils.StringUtils;
 import org.springframework.http.HttpHeaders;
@@ -19,26 +20,21 @@
  *
  * @author ruoyi
  */
-public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper
-{
+public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
     /**
      * @param request
      */
-    public XssHttpServletRequestWrapper(HttpServletRequest request)
-    {
+    public XssHttpServletRequestWrapper(HttpServletRequest request) {
         super(request);
     }
 
     @Override
-    public String[] getParameterValues(String name)
-    {
+    public String[] getParameterValues(String name) {
         String[] values = super.getParameterValues(name);
-        if (values != null)
-        {
+        if (values != null) {
             int length = values.length;
             String[] escapseValues = new String[length];
-            for (int i = 0; i < length; i++)
-            {
+            for (int i = 0; i < length; i++) {
                 // 闃瞲ss鏀诲嚮鍜岃繃婊ゅ墠鍚庣┖鏍�
                 escapseValues[i] = HtmlUtil.cleanHtmlTag(values[i]).trim();
             }
@@ -48,47 +44,44 @@
     }
 
     @Override
-    public ServletInputStream getInputStream() throws IOException
-    {
+    public ServletInputStream getInputStream() throws IOException {
         // 闈瀓son绫诲瀷锛岀洿鎺ヨ繑鍥�
-        if (!isJsonRequest())
-        {
+        if (!isJsonRequest()) {
             return super.getInputStream();
         }
 
         // 涓虹┖锛岀洿鎺ヨ繑鍥�
-        String json = IoUtil.read(super.getInputStream(), StandardCharsets.UTF_8);
-        if (StringUtils.isEmpty(json))
-        {
+        String json = StrUtil.str(IoUtil.readBytes(super.getInputStream(), false), StandardCharsets.UTF_8);
+        if (StringUtils.isEmpty(json)) {
             return super.getInputStream();
         }
 
         // xss杩囨护
         json = HtmlUtil.cleanHtmlTag(json).trim();
-
-        final ByteArrayInputStream bis = IoUtil.toStream(json, StandardCharsets.UTF_8);
-        return new ServletInputStream()
-        {
+        byte[] jsonBytes = json.getBytes(StandardCharsets.UTF_8);
+        final ByteArrayInputStream bis = IoUtil.toStream(jsonBytes);
+        return new ServletInputStream() {
             @Override
-            public boolean isFinished()
-            {
+            public boolean isFinished() {
                 return true;
             }
 
             @Override
-            public boolean isReady()
-            {
+            public boolean isReady() {
                 return true;
             }
 
             @Override
-            public void setReadListener(ReadListener readListener)
-            {
+            public int available() throws IOException {
+                return jsonBytes.length;
             }
 
             @Override
-            public int read() throws IOException
-            {
+            public void setReadListener(ReadListener readListener) {
+            }
+
+            @Override
+            public int read() throws IOException {
                 return bis.read();
             }
         };
@@ -96,11 +89,8 @@
 
     /**
      * 鏄惁鏄疛son璇锋眰
-     *
-     * @param request
      */
-    public boolean isJsonRequest()
-    {
+    public boolean isJsonRequest() {
         String header = super.getHeader(HttpHeaders.CONTENT_TYPE);
         return StringUtils.startsWithIgnoreCase(header, MediaType.APPLICATION_JSON_VALUE);
     }

--
Gitblit v1.9.3