add removeSpecificTags() dangersouHTML
This commit is contained in:
@@ -412,3 +412,20 @@ export const getFormattingDate = (dateString) => {
|
||||
|
||||
return `${month} ${day}, ${year}`;
|
||||
};
|
||||
|
||||
export const removeSpecificTags = (html) => {
|
||||
const tagPatterns = [
|
||||
/<a\b[^>]*>(.*?)<\/a>/gi,
|
||||
/<script\b[^>]*>(.*?)<\/script>/gi,
|
||||
/<iframe\b[^>]*>(.*?)<\/iframe>/gi,
|
||||
/<img\b[^>]*\/?>/gi,
|
||||
/<link\b[^>]*\/?>/gi,
|
||||
];
|
||||
|
||||
let sanitizedHtml = html;
|
||||
tagPatterns.forEach((pattern) => {
|
||||
sanitizedHtml = sanitizedHtml.replace(pattern, "");
|
||||
});
|
||||
|
||||
return sanitizedHtml;
|
||||
};
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
import React from 'react';
|
||||
import React, { useMemo } from "react";
|
||||
|
||||
import { useSelector } from 'react-redux';
|
||||
import { useSelector } from "react-redux";
|
||||
|
||||
import SpotlightContainerDecorator
|
||||
from '@enact/spotlight/SpotlightContainerDecorator';
|
||||
import SpotlightContainerDecorator from "@enact/spotlight/SpotlightContainerDecorator";
|
||||
|
||||
import defaultLogoImg
|
||||
from '../../../../assets/images/ic-tab-partners-default@3x.png';
|
||||
import CustomImage from '../../../components/CustomImage/CustomImage';
|
||||
import { $L } from '../../../utils/helperMethods';
|
||||
import ProductTag from '../components/ProductTag';
|
||||
import StarRating from '../components/StarRating';
|
||||
import css from './ProductOption.module.less';
|
||||
import defaultLogoImg from "../../../../assets/images/ic-tab-partners-default@3x.png";
|
||||
import CustomImage from "../../../components/CustomImage/CustomImage";
|
||||
import { $L, removeSpecificTags } from "../../../utils/helperMethods";
|
||||
import ProductTag from "../components/ProductTag";
|
||||
import StarRating from "../components/StarRating";
|
||||
import css from "./ProductOption.module.less";
|
||||
|
||||
const Container = SpotlightContainerDecorator(
|
||||
{ enterTo: "default-element" },
|
||||
@@ -21,6 +19,12 @@ const Container = SpotlightContainerDecorator(
|
||||
export default function ProductOption({ children, productInfo }) {
|
||||
const { patncLogoPath, prdtId, prdtNm, revwGrd, pmtSuptYn } = productInfo;
|
||||
|
||||
const productNameDangerousHTML = useMemo(() => {
|
||||
const sanitizedString = removeSpecificTags(prdtNm);
|
||||
|
||||
return sanitizedString;
|
||||
}, [productInfo]);
|
||||
|
||||
return (
|
||||
<Container
|
||||
className={css.optionContainer}
|
||||
@@ -40,7 +44,7 @@ export default function ProductOption({ children, productInfo }) {
|
||||
<div
|
||||
className={css.title}
|
||||
aria-label={prdtNm}
|
||||
dangerouslySetInnerHTML={{ __html: prdtNm }}
|
||||
dangerouslySetInnerHTML={{ __html: productNameDangerousHTML }}
|
||||
/>
|
||||
|
||||
<div className={css.bottomLayer}>
|
||||
|
||||
@@ -14,7 +14,12 @@ import TButtonTab from "../../../../components/TButtonTab/TButtonTab";
|
||||
import TPopUp from "../../../../components/TPopUp/TPopUp";
|
||||
import TQRCode from "../../../../components/TQRCode/TQRCode";
|
||||
import * as Config from "../../../../utils/Config";
|
||||
import { $L, scaleH, scaleW } from "../../../../utils/helperMethods";
|
||||
import {
|
||||
$L,
|
||||
removeSpecificTags,
|
||||
scaleH,
|
||||
scaleW,
|
||||
} from "../../../../utils/helperMethods";
|
||||
import ProductTag from "../../components/ProductTag";
|
||||
import StarRating from "../../components/StarRating";
|
||||
import css from "./IndicatorOptions.module.less";
|
||||
@@ -73,7 +78,8 @@ export default function IndicatorOptions({
|
||||
[dispatch, handleIndicatorOptions]
|
||||
);
|
||||
const productDescription = () => {
|
||||
return { __html: description };
|
||||
const sanitizedString = removeSpecificTags(description);
|
||||
return { __html: sanitizedString };
|
||||
};
|
||||
|
||||
const onSpotlightLeft = (e) => {
|
||||
|
||||
@@ -7,7 +7,7 @@ import Spottable from "@enact/spotlight/Spottable";
|
||||
import defaultLogoImg from "../../../../assets/images/ic-tab-partners-default@3x.png";
|
||||
import CustomImage from "../../../components/CustomImage/CustomImage";
|
||||
import { convertUtcToLocal } from "../../../components/MediaPlayer/util";
|
||||
import { $L } from "../../../utils/helperMethods";
|
||||
import { $L, removeSpecificTags } from "../../../utils/helperMethods";
|
||||
import css from "./PlayerItemCard.module.less";
|
||||
|
||||
const SpottableComponent = Spottable("div");
|
||||
|
||||
@@ -8,7 +8,7 @@ import defaultImage from "../../../../../assets/images/img-thumb-empty-144@3x.pn
|
||||
import { updatePanel } from "../../../../actions/panelActions";
|
||||
import TVirtualGridList from "../../../../components/TVirtualGridList/TVirtualGridList";
|
||||
import { LOG_MENU, panel_names } from "../../../../utils/Config";
|
||||
import { $L } from "../../../../utils/helperMethods";
|
||||
import { $L, removeSpecificTags } from "../../../../utils/helperMethods";
|
||||
import PlayerItemCard, { TYPES } from "../../PlayerItemCard/PlayerItemCard";
|
||||
import ListEmptyContents from "../TabContents/ListEmptyContents/ListEmptyContents";
|
||||
import css from "./LiveChannelContents.module.less";
|
||||
@@ -65,7 +65,8 @@ export default function FeaturedShowContents({
|
||||
} = featuredShowsInfos[index];
|
||||
|
||||
const showNameDangerouslySetInnerHTML = () => {
|
||||
return { __html: showNm };
|
||||
const sanitizedString = removeSpecificTags(showNm);
|
||||
return { __html: sanitizedString };
|
||||
};
|
||||
return (
|
||||
<PlayerItemCard
|
||||
|
||||
Reference in New Issue
Block a user