Skip to content

Commit

Permalink
Removed sanitizing from dangerouslySetInnerHTML
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasnp authored and kennethmyhra committed Jul 5, 2022
1 parent f22d319 commit bdd267d
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 15 deletions.
3 changes: 1 addition & 2 deletions src/components/formcomponents/display/display.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as React from 'react';

import DOMPurify from 'dompurify';
import { connect } from 'react-redux';

import { Questionnaire, QuestionnaireItem } from '../../../types/fhir';
Expand Down Expand Up @@ -40,7 +39,7 @@ const Display: React.SFC<Props> = ({ id, enable, pdf, item, questionnaire, onRen
id={getId(id)}
className={`page_refero__markdown ${designsystemtypography['anchorlink-wrapper']}`}
dangerouslySetInnerHTML={{
__html: DOMPurify.sanitize(getText(item, onRenderMarkdown, questionnaire)),
__html: getText(item, onRenderMarkdown, questionnaire),
}}
/>
);
Expand Down
4 changes: 1 addition & 3 deletions src/components/formcomponents/label.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import * as React from 'react';

import DOMPurify from 'dompurify';

import { QuestionnaireItem, Questionnaire } from '../../types/fhir';

import { getText, renderPrefix } from '../../util/index';
Expand All @@ -16,7 +14,7 @@ const Label = ({ item, onRenderMarkdown, questionnaire }: Props): JSX.Element |
return (
<span
dangerouslySetInnerHTML={{
__html: DOMPurify.sanitize(`${renderPrefix(item)} ${getText(item, onRenderMarkdown, questionnaire)}`),
__html: `${renderPrefix(item)} ${getText(item, onRenderMarkdown, questionnaire)}`,
}}
/>
);
Expand Down
4 changes: 1 addition & 3 deletions src/components/formcomponents/sublabel.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import * as React from 'react';

import DOMPurify from 'dompurify';

interface Props {
subLabelText: string;
}
Expand All @@ -11,7 +9,7 @@ const SubLabel = ({ subLabelText }: Props): JSX.Element | null => {
<span
className="page_refero__sublabel"
dangerouslySetInnerHTML={{
__html: DOMPurify.sanitize(subLabelText),
__html: subLabelText,
}}
/>
);
Expand Down
3 changes: 1 addition & 2 deletions src/components/formcomponents/text/text.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as React from 'react';

import DOMPurify from 'dompurify';
import { connect } from 'react-redux';
import { ThunkDispatch } from 'redux-thunk';

Expand Down Expand Up @@ -139,7 +138,7 @@ export class Text extends React.Component<Props & ValidationProps, {}> {
id={id}
className="page_refero__component page_refero__component_highlight"
dangerouslySetInnerHTML={{
__html: DOMPurify.sanitize(`${getText(item, onRenderMarkdown, questionnaire)}`),
__html: `${getText(item, onRenderMarkdown, questionnaire)}`,
}}
/>
);
Expand Down
4 changes: 1 addition & 3 deletions src/components/formcomponents/textview.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import * as React from 'react';

import DOMPurify from 'dompurify';

import { QuestionnaireItem } from '../../types/fhir';

import { renderPrefix, getText, getId } from '../../util/index';
Expand All @@ -17,7 +15,7 @@ interface Props {
const textView: React.SFC<Props> = ({ id, item, value, textClass, children, onRenderMarkdown }) => {
return (
<div id={getId(id)}>
<b dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(`${renderPrefix(item)} ${getText(item, onRenderMarkdown)} `) }} />
<b dangerouslySetInnerHTML={{ __html: `${renderPrefix(item)} ${getText(item, onRenderMarkdown)}` }} />
<div className={textClass || ''}>{value}</div>
{children ? (
<span>
Expand Down
3 changes: 1 addition & 2 deletions src/components/with-common-functions.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from 'react';

import classNames from 'classnames';
import DOMPurify from 'dompurify';
import { Collapse } from 'react-collapse';
import { ThunkDispatch } from 'redux-thunk';

Expand Down Expand Up @@ -238,7 +237,7 @@ export default function withCommonFunctions<T>(WrappedComponent: React.Component
});
return (
<Collapse isOpened={this.state.isHelpVisible}>
<div className={collapseClasses} dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(`${getText(helpItem)}`) }} />
<div className={collapseClasses} dangerouslySetInnerHTML={{ __html: `${getText(helpItem)}` }} />
</Collapse>
);
};
Expand Down

0 comments on commit bdd267d

Please sign in to comment.