Просмотр исходного кода

fix(security): codescan fails to scan fix (#837)

Yiwei Mao 3 месяцев назад
Родитель
Сommit
ee9a6f3423

+ 4 - 5
packages/canvas-engine/free-layout-core/src/utils/get-url-params.ts

@@ -12,12 +12,11 @@ export function getUrlParams(): Record<string, string> {
 
       const [k, v] = key.split('=');
 
-      // Prevent prototype pollution attack, filter dangerous attribute names
-      if (k === '__proto__' || k === 'constructor' || k === 'prototype') {
-        return res;
-      }
-
       if (k) {
+        // Prevent prototype pollution attack, filter dangerous attribute names
+        if (k === '__proto__' || k === 'constructor' || k === 'prototype') {
+          return res;
+        }
         res[k] = v || '';
       }
       return res;