[docs] sanitize html input for comments (#2677)

This commit is contained in:
Gandharv 2022-03-31 08:39:47 +05:00 committed by GitHub
parent b721cd4150
commit b55b260c89
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,6 +9,7 @@ import CommentFooter from '@/Editor/Comment/CommentFooter';
import usePopover from '@/_hooks/use-popover';
import { commentsService } from '@/_services';
import useRouter from '@/_hooks/use-router';
import DOMPurify from 'dompurify';
const Comment = ({
socket,
@ -78,7 +79,7 @@ const Comment = ({
const handleSubmit = async (comment) => {
await commentsService.createComment({
threadId,
comment,
comment: DOMPurify.sanitize(comment),
appVersionsId,
});
socket.send(
@ -97,7 +98,7 @@ const Comment = ({
};
const handleEdit = async (comment, cid) => {
await commentsService.updateComment(cid, { comment });
await commentsService.updateComment(cid, { comment: DOMPurify.sanitize(comment) });
fetchData();
socket.send(
JSON.stringify({