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

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

Yiwei Mao 3 месяцев назад
Родитель
Сommit
ee9a6f3423
1 измененных файлов с 4 добавлено и 5 удалено
  1. 4 5
      packages/canvas-engine/free-layout-core/src/utils/get-url-params.ts

+ 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('=');
       const [k, v] = key.split('=');
 
 
-      // Prevent prototype pollution attack, filter dangerous attribute names
-      if (k === '__proto__' || k === 'constructor' || k === 'prototype') {
-        return res;
-      }
-
       if (k) {
       if (k) {
+        // Prevent prototype pollution attack, filter dangerous attribute names
+        if (k === '__proto__' || k === 'constructor' || k === 'prototype') {
+          return res;
+        }
         res[k] = v || '';
         res[k] = v || '';
       }
       }
       return res;
       return res;