From cd82db16d54eac720a53b47e346b4002124a60fa Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sun, 28 Apr 2024 00:49:03 +1200 Subject: [PATCH] Add DOMPurify config options --- client/homebrew/brewRenderer/brewRenderer.jsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/client/homebrew/brewRenderer/brewRenderer.jsx b/client/homebrew/brewRenderer/brewRenderer.jsx index 799e21d66..57bee68ca 100644 --- a/client/homebrew/brewRenderer/brewRenderer.jsx +++ b/client/homebrew/brewRenderer/brewRenderer.jsx @@ -15,6 +15,7 @@ const Frame = require('react-frame-component').default; const dedent = require('dedent-tabs').default; const DOMPurify = require('dompurify'); +const purifyConfig = { FORCE_BODY: true, ADD_ATTR: ['style'] }; const Themes = require('themes/themes.json'); @@ -35,8 +36,7 @@ const BrewPage = (props)=>{ index : 0, ...props }; - const cleanText = DOMPurify.sanitize(props.contents); - // console.log(DOMPurify.removed); + const cleanText = DOMPurify.sanitize(props.contents, purifyConfig); return
; @@ -125,8 +125,7 @@ const BrewRenderer = (props)=>{ const renderStyle = ()=>{ if(!props.style) return; - const cleanStyle = DOMPurify.sanitize(props.style); - // console.log(DOMPurify.removed); + const cleanStyle = DOMPurify.sanitize(props.style, purifyConfig); //return
@layer styleTab {\n${sanitizeScriptTags(props.style)}\n} ` }} />; return
${cleanStyle} ` }} />; };