Skip to content

Commit

Permalink
Merge pull request #300 from ODOICHON/fix/#299
Browse files Browse the repository at this point in the history
[fix] ๋†๊ฐ€๊ฑฐ๋ž˜ ๊ฒŒ์‹œ๊ธ€ ์ˆ˜์ • ์‹œ ๊ธฐ์กด ๊ฒŒ์‹œ๊ธ€ ์ƒ์„ธ๋‚ด์šฉ์ด ๋ถˆ๋Ÿฌ์™€์ง€์ง€ ์•Š๋Š” ์ด์Šˆ
  • Loading branch information
sangminlee98 authored Sep 23, 2024
2 parents 86dcefd + ca183a0 commit 733e240
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/components/Community/Quill/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import ReactQuill from 'react-quill';
import 'react-quill/dist/quill.snow.css';
import { useLocation, useNavigate } from 'react-router-dom';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import DOMPurify from 'dompurify';
import ModalPortal from '@/components/Common/ModalPortal';
import ToastMessageModal from '@/components/Common/ToastMessageModal';
import { QueryKeys, restFetcher } from '@/queryClient';
Expand Down Expand Up @@ -165,7 +166,7 @@ export default function CommunityQuill({ queryParam }: CommunityQuillProps) {
if (boardData) {
QuillRef.current
?.getEditor()
.clipboard.dangerouslyPasteHTML(0, boardData.code);
.clipboard.dangerouslyPasteHTML(0, DOMPurify.sanitize(boardData.code));
}
return () => {
if (!isProcessingRef.current) {
Expand Down
3 changes: 2 additions & 1 deletion src/components/Introduce/Quill/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'react-quill/dist/quill.snow.css';
import { useLocation, useNavigate } from 'react-router-dom';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { AxiosError } from 'axios';
import DOMPurify from 'dompurify';
import ModalPortal from '@/components/Common/ModalPortal';
import ToastMessageModal from '@/components/Common/ToastMessageModal';
import { QueryKeys, restFetcher } from '@/queryClient';
Expand Down Expand Up @@ -181,7 +182,7 @@ export default function IntroduceQuill() {
if (boardData) {
QuillRef.current
?.getEditor()
.clipboard.dangerouslyPasteHTML(0, boardData.code);
.clipboard.dangerouslyPasteHTML(0, DOMPurify.sanitize(boardData.code));
}
return () => {
if (!isProcessingRef.current) {
Expand Down
5 changes: 5 additions & 0 deletions src/components/Trade/Quill/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ export default function TradeQuill({
}, [images, isProcessing]);

useEffect(() => {
if (form.code !== '') {
QuillRef.current
?.getEditor()
.clipboard.dangerouslyPasteHTML(0, form.code);
}
return () => {
if (!isProcessingRef.current) {
deleteFile(imagesRef.current);
Expand Down
7 changes: 6 additions & 1 deletion src/pages/Main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useState } from 'react';
import { Link, useNavigate } from 'react-router-dom';
import { useQuery } from '@tanstack/react-query';
import dayjs from 'dayjs';
import DOMPurify from 'dompurify';
import { motion } from 'framer-motion';
import { Autoplay, Pagination, Navigation } from 'swiper/modules';
import { Swiper, SwiperSlide } from 'swiper/react';
Expand Down Expand Up @@ -85,7 +86,11 @@ export default function MainPage() {
}}
>
<h3>0{idx + 1}</h3>
<h1 dangerouslySetInnerHTML={{ __html: data.title }} />
<h1
dangerouslySetInnerHTML={{
__html: DOMPurify.sanitize(data.title),
}}
/>
<p>{data.content}</p>
</SwiperSlide>
))}
Expand Down

0 comments on commit 733e240

Please sign in to comment.