From 7fb13cf54b76bb5f5f28431ac89cf3c4c6b11b04 Mon Sep 17 00:00:00 2001 From: _Bastler <_Bastler@bstly.de> Date: Thu, 28 Oct 2021 19:15:02 +0200 Subject: [PATCH] santitize, popup class --- front/src/Api/Events/OpenPopupEvent.ts | 1 + front/src/Api/iframe/ui.ts | 3 ++- .../LayoutManager/LayoutManager.svelte | 17 +++-------------- front/src/Phaser/Game/GameScene.ts | 6 ++++-- front/src/WebRtc/HtmlUtils.ts | 16 ++++++++++++++++ front/src/iframe_api.ts | 4 ++-- front/style/style.scss | 15 +++++++++++++++ 7 files changed, 43 insertions(+), 19 deletions(-) diff --git a/front/src/Api/Events/OpenPopupEvent.ts b/front/src/Api/Events/OpenPopupEvent.ts index 9ac120bd..7d7556fb 100644 --- a/front/src/Api/Events/OpenPopupEvent.ts +++ b/front/src/Api/Events/OpenPopupEvent.ts @@ -13,6 +13,7 @@ export const isOpenPopupEvent = new tg.IsInterface() targetObject: tg.isString, message: tg.isString, buttons: tg.isArray(isButtonDescriptor), + popupClass : tg.isString, input: tg.isBoolean }).get(); diff --git a/front/src/Api/iframe/ui.ts b/front/src/Api/iframe/ui.ts index ce39bebe..87301f68 100644 --- a/front/src/Api/iframe/ui.ts +++ b/front/src/Api/iframe/ui.ts @@ -85,7 +85,7 @@ export class WorkAdventureUiCommands extends IframeApiContribution void>(); @@ -113,6 +113,7 @@ export class WorkAdventureUiCommands extends IframeApiContribution import { layoutManagerActionStore } from "../../Stores/LayoutManagerStore"; - const sanitizeHtml = require('sanitize-html'); - + import { HtmlUtils } from "../../WebRtc/HtmlUtils"; function onClick(callback: () => void) { callback(); } - function sanitize(html : string | number | boolean | undefined) { - return sanitizeHtml(html, { - allowedAttributes: { - 'span': ['style'], - }, - allowedStyles: { - 'span': { - 'color': [/^#(0x)?[0-9a-f]+$/i, /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/], - 'font-size': [/^\d+(?:px|em|%)$/] - } - } - }); + function sanitize(html : string) { + return HtmlUtils.sanitize(html); } diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 92351cc7..3a3c7bc5 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -97,6 +97,8 @@ import { analyticsClient } from "../../Administration/AnalyticsClient"; import { get } from "svelte/store"; import { contactPageStore } from "../../Stores/MenuStore"; + + export interface GameSceneInitInterface { initPosition: PointInterface | null; reconnecting: boolean; @@ -921,7 +923,7 @@ export class GameScene extends DirtyScene { ); return; } - const escapedMessage = HtmlUtils.escapeHtml(openPopupEvent.message); + const escapedMessage = HtmlUtils.sanitize(openPopupEvent.message); let html = `