mirror of
https://github.com/wassname/talk.git
synced 2026-08-19 12:40:16 +08:00
[next] DOM Purification (#2115)
* feat: added purify + linkify + better link detection * fix: linting + tests * chore: refactor RequireProperty Type
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
import cn from "classnames";
|
||||
import dompurify from "dompurify";
|
||||
import React, { StatelessComponent } from "react";
|
||||
|
||||
import { createPurify } from "talk-common/utils/purify";
|
||||
|
||||
import styles from "./HTMLContent.css";
|
||||
|
||||
/**
|
||||
* Create a purify instance that will be used to handle HTML content.
|
||||
*/
|
||||
const purify = createPurify(window, false);
|
||||
|
||||
interface HTMLContentProps {
|
||||
children: string;
|
||||
className?: string;
|
||||
@@ -15,7 +21,7 @@ const HTMLContent: StatelessComponent<HTMLContentProps> = ({
|
||||
}) => (
|
||||
<div
|
||||
className={cn(styles.root, className)}
|
||||
dangerouslySetInnerHTML={{ __html: dompurify.sanitize(children) }}
|
||||
dangerouslySetInnerHTML={{ __html: purify.sanitize(children) }}
|
||||
/>
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user