From 93ee021b6e8a9e6b3bca12c2f35f6e3c68baef5a Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: Sat, 31 Jul 2021 12:18:24 +0800
Subject: [PATCH] XSS过滤排除非json类型

---
 ruoyi-ui/src/utils/ruoyi.js |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/ruoyi-ui/src/utils/ruoyi.js b/ruoyi-ui/src/utils/ruoyi.js
index 22e1ebf..ee01f9b 100644
--- a/ruoyi-ui/src/utils/ruoyi.js
+++ b/ruoyi-ui/src/utils/ruoyi.js
@@ -179,11 +179,21 @@
 * @param {*} params  参数
 */
 export function tansParams(params) {
-	let result = ''
-	Object.keys(params).forEach((key) => {
-		if (!Object.is(params[key], undefined) && !Object.is(params[key], null) && !Object.is(JSON.stringify(params[key]), '{}')) {
-			result += encodeURIComponent(key) + '=' + encodeURIComponent(params[key]) + '&'
-		}
-	})
-	return result
+    let result = ''
+    for (const propName of Object.keys(params)) {
+        const value = params[propName];
+        var part = encodeURIComponent(propName) + "=";
+        if (value !== null && typeof(value) !== "undefined") {
+            if (typeof value === 'object') {
+                for (const key of Object.keys(value)) {
+                    let params = propName + '[' + key + ']';
+                    var subPart = encodeURIComponent(params) + "=";
+                    result += subPart + encodeURIComponent(value[key]) + "&";
+                }
+            } else {
+                result += part + encodeURIComponent(value) + "&";
+           }
+        }
+    }
+    return result
 }

--
Gitblit v1.9.3