Skip to content

PM-226 Fix React bad practice: dangerouslySetInnerhtml #1594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/components/ChallengeEditor/ChallengeView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import PropTypes from 'prop-types'
import cn from 'classnames'
import { withRouter } from 'react-router-dom'
import styles from './ChallengeView.module.scss'
import xss from 'xss'
import Track from '../../Track'
import NDAField from '../NDAField'
import UseSchedulingAPIField from '../UseSchedulingAPIField'
Expand Down Expand Up @@ -114,10 +113,7 @@ const ChallengeView = ({
<div className={cn(styles.row, styles.topRow)}>
<div className={styles.col}>
<span>
<span className={styles.fieldTitle}>Project:</span>
<span dangerouslySetInnerHTML={{
__html: xss(projectDetail ? projectDetail.name : '')
}} />
<span className={styles.fieldTitle}>Project: {projectDetail ? projectDetail.name : ''}</span>
</span>
</div>
{selectedMilestone &&
Expand Down
7 changes: 1 addition & 6 deletions src/components/ChallengeEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import moment from 'moment-timezone'
import { pick } from 'lodash/fp'
import { withRouter } from 'react-router-dom'
import { toastr } from 'react-redux-toastr'
import xss from 'xss'

import {
VALIDATION_VALUE_TYPE,
PRIZE_SETS_TYPE,
Expand Down Expand Up @@ -1704,10 +1702,7 @@ class ChallengeEditor extends Component {
<div className={cn(styles.row, styles.topRow)}>
<div className={styles.col}>
<span>
<span className={styles.fieldTitle}>Project:</span>
<span dangerouslySetInnerHTML={{
__html: xss(projectDetail ? projectDetail.name : '')
}} />
<span className={styles.fieldTitle}>Project: {projectDetail ? projectDetail.name : ''}</span>
</span>
</div>
<div className={styles.col}>
Expand Down
10 changes: 3 additions & 7 deletions src/components/ChallengesComponent/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { CONNECT_APP_URL, PROJECT_ROLES } from '../../config/constants'
import { PrimaryButton } from '../Buttons'
import ChallengeList from './ChallengeList'
import styles from './ChallengesComponent.module.scss'
import xss from 'xss'
import { checkReadOnlyRoles } from '../../util/tc'

const ChallengesComponent = ({
Expand Down Expand Up @@ -61,12 +60,9 @@ const ChallengesComponent = ({
<Helmet title={activeProject ? activeProject.name : ''} />
{!dashboard && <div className={styles.titleContainer}>
<div className={styles.titleLinks}>
<div
className={styles.title}
dangerouslySetInnerHTML={{
__html: xss(activeProject ? activeProject.name : '')
}}
/>
<div className={styles.title}>
{activeProject ? activeProject.name : ''}
</div>
{activeProject && activeProject.id && (
<span>
(
Expand Down
3 changes: 1 addition & 2 deletions src/components/ProjectCard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react'
import PT from 'prop-types'
import { Link } from 'react-router-dom'
import cn from 'classnames'
import xss from 'xss'

import styles from './ProjectCard.module.scss'

Expand All @@ -14,7 +13,7 @@ const ProjectCard = ({ projectName, projectId, selected, setActiveProject }) =>
className={cn(styles.projectName, { [styles.selected]: selected })}
onClick={() => setActiveProject(parseInt(projectId))}
>
<div className={styles.name} dangerouslySetInnerHTML={{ __html: xss(projectName) }} />
<div className={styles.name}>{projectName}</div>
</Link>
</div>
)
Expand Down
Loading