From 886a7e82705f366a6ee49f3cafcb08502884afd8 Mon Sep 17 00:00:00 2001 From: clovis Date: Mon, 3 Jun 2024 15:10:41 +0200 Subject: [PATCH] fix: no style on views --- .gitignore | 3 ++- template/src/sanitize.tsx | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index b512c09..006562a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -node_modules \ No newline at end of file +node_modules +.yarn \ No newline at end of file diff --git a/template/src/sanitize.tsx b/template/src/sanitize.tsx index 4d684dd..20aec95 100644 --- a/template/src/sanitize.tsx +++ b/template/src/sanitize.tsx @@ -1,12 +1,23 @@ import xss from 'xss'; +const allowed = ["class"]; + +// @ts-expect-error no types +const whiteList = Object.keys(xss.whiteList).reduce((acc, key) => { + // @ts-expect-error no types + const value = [...xss.whiteList[key], ...allowed]; + return { + ...acc, + [key]: value, + } +}, {}); + const options = { whiteList: { - // @ts-expect-error no types - ...xss.whiteList, - main: [], - svg: [], - time: [], + ...whiteList, + main: allowed, + svg: allowed, + time: allowed, } }