Skip to content

Commit dc9b747

Browse files
committed
Added DOMPurify sanitization to Page.jsx with allowed tags/attributes and Added null safety check for SVG rendering in SplashViz.jsx
1 parent 4549782 commit dc9b747

2 files changed

Lines changed: 44 additions & 2 deletions

File tree

src/components/Page/Page.jsx

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,49 @@ export default function Page(props) {
9999
contentRender = (
100100
<div
101101
dangerouslySetInnerHTML={{
102-
__html: DOMPurify.sanitize(content),
102+
__html: DOMPurify.sanitize(content, {
103+
ALLOWED_TAGS: [
104+
"h1",
105+
"h2",
106+
"h3",
107+
"h4",
108+
"h5",
109+
"h6",
110+
"p",
111+
"a",
112+
"em",
113+
"strong",
114+
"b",
115+
"i",
116+
"code",
117+
"pre",
118+
"div",
119+
"span",
120+
"ul",
121+
"ol",
122+
"li",
123+
"table",
124+
"thead",
125+
"tbody",
126+
"tr",
127+
"td",
128+
"th",
129+
"blockquote",
130+
"hr",
131+
"br",
132+
"img",
133+
"button",
134+
],
135+
ALLOWED_ATTR: [
136+
"href",
137+
"title",
138+
"src",
139+
"alt",
140+
"class",
141+
"id",
142+
"data-clipboard-text",
143+
],
144+
}),
103145
}}
104146
/>
105147
);

src/components/SplashViz/SplashViz.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default class SplashViz extends Component {
2626
</h1>
2727
<div
2828
className="splash-viz__modules"
29-
dangerouslySetInnerHTML={{ __html: HomeSVG.body }}
29+
dangerouslySetInnerHTML={{ __html: HomeSVG?.body || "" }}
3030
></div>
3131
<Cube
3232
className="splash-viz__cube"

0 commit comments

Comments
 (0)