fix xss from iframe name

This commit is contained in:
Paul Mineev
2022-04-10 15:35:09 -05:00
committed by Umputun
parent 145b4c474c
commit fe6b119254
2 changed files with 9 additions and 6 deletions
+1 -1
View File
@@ -56,7 +56,7 @@ export function postMessageToIframe(target: HTMLIFrameElement, data: ChildMessag
*/
export function parseMessage({ data }: MessageEvent): AllMessages {
if (typeof data !== 'object' || data === null || Array.isArray(data)) {
return {} as AllMessages;
return {};
}
return data as AllMessages;
+8 -5
View File
@@ -19,13 +19,16 @@
return window.CSS && window.CSS.supports && window.CSS.supports('color', 'var(--fake-var)');
}
if (isCSSVariablesSupported()) {
var name;
try {
name = JSON.parse(window.name);
if (name.__colors__) {
const colors = name.__colors__;
var name = JSON.parse(window.name);
var colors = name.__colors__;
var root = document.documentElement;
if (colors) {
for (var color in colors) {
var root = document.documentElement;
if (!color.startsWith('--')) {
console.info('Key ' + color + ' must start with `--`');
continue;
}
root.style.setProperty(color, colors[color]);
}
}