Skip to content

Commit

Permalink
Replace escapeHTML (used by mistake) with xss for sanitization
Browse files Browse the repository at this point in the history
  • Loading branch information
Keeqler committed Jun 3, 2024
1 parent 85ead11 commit d89fe9b
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 6 deletions.
4 changes: 2 additions & 2 deletions components/BigDumbMarkdown.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import escapeHTML from 'escape-html'
import xss from 'xss'
import markdownStyles from './markdown-styles.module.css'

export default function BigDumbMarkdown({ content }: { content: string }) {
return (
<div className="flex flex-col items-center py-8">
<div className={markdownStyles['markdown']}>
<div dangerouslySetInnerHTML={{ __html: escapeHTML(content) }} />
<div dangerouslySetInnerHTML={{ __html: xss(content) }} />
</div>
</div>
)
Expand Down
49 changes: 48 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"stripe": "^15.9.0",
"swr": "^2.2.5",
"watch": "^0.13.0",
"wicg-inert": "^3.1.2"
"wicg-inert": "^3.1.2",
"xss": "^1.0.15"
},
"devDependencies": {
"@tailwindcss/line-clamp": "^0.4.4",
Expand Down
4 changes: 2 additions & 2 deletions pages/projects/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Link from 'next/link'
import ShareButtons from '../../components/ShareButtons'
import Progress from '../../components/Progress'
import { fetchPostJSON, fetchGetJSONAuthedBTCPay, fetchGetJSONAuthedStripe } from '../../utils/api-helpers'
import escapeHTML from 'escape-html'
import xss from 'xss'

type SingleProjectPageProps = {
project: ProjectItem
Expand Down Expand Up @@ -138,7 +138,7 @@ const Project: NextPage<SingleProjectPageProps> = ({ project, projects, stats })
</p >
<ShareButtons project={project} />
<hr />
{content && <div dangerouslySetInnerHTML={{ __html: escapeHTML(content) }} />}
{content && <div dangerouslySetInnerHTML={{ __html: xss(content) }} />}
</div >
</article >
</div >
Expand Down

0 comments on commit d89fe9b

Please sign in to comment.