Skip to content

Commit

Permalink
Dont Dangerously Render HTML (#11526)
Browse files Browse the repository at this point in the history
Co-authored-by: Nicholas Summers <[email protected]>
  • Loading branch information
ntsummers1 and Nicholas Summers authored Nov 22, 2023
1 parent fcc73df commit af3223f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Box, Image, Td, Text, Tr } from "@chakra-ui/react";
// types
import { EntityShape, ModalOverlayReportPageShape, ReportType } from "types";
// utils
import { assertExhaustive, getEntityDetailsMLR, renderHtml } from "utils";
import { assertExhaustive, getEntityDetailsMLR } from "utils";
// verbiage
import mcparVerbiage from "../../verbiage/pages/mcpar/mcpar-export";
import mlrVerbiage from "../../verbiage/pages/mlr/mlr-export";
Expand Down Expand Up @@ -86,7 +86,7 @@ export function renderModalOverlayTableBody(
<Text sx={sx.entityList}>
{entity.report_planName ?? "Not entered"} <br />
{report_programName} <br />
{renderHtml(mlrEligibilityGroup)} <br />
{mlrEligibilityGroup} <br />
{reportingPeriod}
</Text>
</Td>
Expand Down
4 changes: 2 additions & 2 deletions services/ui-src/src/components/tables/EntityRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { EntityStatusIcon } from "components";
// types
import { AnyObject, EntityShape } from "types";
// utils
import { eligibilityGroup, renderHtml, useUser } from "utils";
import { eligibilityGroup, useUser } from "utils";
// assets
import deleteIcon from "assets/icons/icon_cancel_x_circle.png";
import { useContext, useMemo } from "react";
Expand Down Expand Up @@ -44,7 +44,7 @@ export const EntityRow = ({
<Td sx={sx.programInfo}>
<ul>
{programInfo.map((field, index) => (
<li key={index}>{renderHtml(field)}</li>
<li key={index}>{field}</li>
))}
</ul>
{!entityComplete && report?.reportType === "MLR" && (
Expand Down
7 changes: 0 additions & 7 deletions services/ui-src/src/utils/other/rendering.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import React from "react";
import { EntityShape } from "types";

// render '<' special character
export const renderHtml = (rawHTML: string) =>
React.createElement("span", {
dangerouslySetInnerHTML: { __html: rawHTML },
});

// return MLR eligibility group text
export const eligibilityGroup = (entity: EntityShape) => {
if (entity["report_eligibilityGroup-otherText"]) {
Expand Down

0 comments on commit af3223f

Please sign in to comment.