-
Notifications
You must be signed in to change notification settings - Fork 820
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
63b349c
commit 74ade7b
Showing
9 changed files
with
103 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,33 @@ | ||
import { | ||
convertImageLinksToHtml, | ||
convertNewLinesToBreaks, | ||
} from "components/apps/Messenger/functions"; | ||
import { sanitize } from "dompurify"; | ||
import { useMemo } from "react"; | ||
|
||
const SanitizedContent: FC<{ content: string }> = ({ content }) => ( | ||
<div | ||
// eslint-disable-next-line react/no-danger | ||
dangerouslySetInnerHTML={{ | ||
__html: sanitize(content, { | ||
ALLOWED_ATTR: ["src"], | ||
ALLOWED_TAGS: ["br", "img"], | ||
}), | ||
}} | ||
/> | ||
); | ||
const SanitizedContent: FC<{ content: string; decrypted: boolean }> = ({ | ||
content, | ||
decrypted, | ||
}) => { | ||
const decryptedContent = useMemo( | ||
() => | ||
decrypted | ||
? convertImageLinksToHtml(convertNewLinesToBreaks(content)) | ||
: "", | ||
[content, decrypted] | ||
); | ||
|
||
return ( | ||
<div | ||
// eslint-disable-next-line react/no-danger | ||
dangerouslySetInnerHTML={{ | ||
__html: sanitize(decryptedContent || content, { | ||
ALLOWED_ATTR: ["src"], | ||
ALLOWED_TAGS: ["br", "img"], | ||
}), | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
export default SanitizedContent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters