Skip to content

Commit

Permalink
fix: use same libary for dom sanitation as covapp
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielHabenicht committed Feb 4, 2022
1 parent cb88365 commit a7492cd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
1 change: 1 addition & 0 deletions covquestions-editor-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"clsx": "^1.1.1",
"comlink-loader": "^2.0.0",
"copyfiles": "^2.4.1",
"dompurify": "^2.3.5",
"fast-deep-equal": "^3.1.3",
"jest-date-mock": "^1.0.8",
"json-logic-js": "^2.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Primitive, Question, Questionnaire, QuestionnaireEngine } from "@covope
import { ResultComponent } from "./ResultComponent";
import "typeface-fira-sans";
import { QuestionFormComponent } from "./questionComponents/QuestionFormComponent";
import sanitizeHtml from "sanitize-html";
import DOMPurify from 'dompurify';

type QuestionnaireExecutionProps = {
currentQuestionnaire: Questionnaire;
Expand Down Expand Up @@ -137,9 +137,7 @@ export const QuestionnaireExecution: React.FC<QuestionnaireExecutionProps> = ({
<Typography
className={classes.questionDetails}
dangerouslySetInnerHTML={{
__html: sanitizeHtml(currentQuestion.details, {
allowedTags: sanitizeHtml.defaults.allowedTags.concat([ 'img' ])
}),
__html: DOMPurify.sanitize(currentQuestion.details),
}}
/>
</Grid>
Expand Down
6 changes: 2 additions & 4 deletions covquestions-editor-app/src/components/ResultComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { Result } from "@covopen/covquestions-js";
import { createStyles, Grid, makeStyles, Paper, Typography } from "@material-ui/core";
import sanitizeHtml from "sanitize-html";
import DOMPurify from 'dompurify';

const useStyles = makeStyles(() =>
createStyles({
Expand Down Expand Up @@ -36,9 +36,7 @@ export const ResultComponent: React.FC<{ results: Result[] }> = ({ results }) =>
<Typography
className={classes.resultText}
dangerouslySetInnerHTML={{
__html: sanitizeHtml(result.result.text, {
allowedTags: sanitizeHtml.defaults.allowedTags.concat([ 'img' ])
}),
__html: DOMPurify.sanitize(result.result.text),
}}
/>
</Grid>
Expand Down

0 comments on commit a7492cd

Please sign in to comment.