@blocklet/pages-kit 0.5.35 → 0.5.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,6 +11,9 @@ export function injectPreloadComponents(data) {
11
11
  })),
12
12
  instances: Object.fromEntries(data.instances.map(({ id, ...instance }) => [id, instance])),
13
13
  };
14
+ // Base64 encode the JSON data to prevent XSS injection
15
+ const jsonString = JSON.stringify(injectState);
16
+ const base64Data = Buffer.from(jsonString, 'utf8').toString('base64');
14
17
  return {
15
18
  html: `\
16
19
  ${Object.values(data.components)
@@ -22,7 +25,7 @@ ${script}
22
25
  .join('\n')}
23
26
 
24
27
  <script>
25
- var ${PreloadComponentsStateGlobalVariableName} = ${JSON.stringify(injectState)}
28
+ var ${PreloadComponentsStateGlobalVariableName} = JSON.parse(atob('${base64Data}'));
26
29
  </script>
27
30
  `,
28
31
  };