@@ -34,6 +34,10 @@ const ALLOWED_TAGS = [
3434
3535const ALLOWED_ATTR = [ 'href' , 'class' , 'id' , 'style' , 'data-comment-index' ] ;
3636
37+ // 명시적으로 금지할 태그 / 속성 (iframe, script, on* 이벤트 등)
38+ const FORBID_TAGS = [ 'iframe' , 'script' ] ;
39+ const FORBID_ATTR = [ 'onerror' , 'onclick' , 'onload' , / ^ o n .* / ] ;
40+
3741const WikiContent = ( { author, DocTitle, content, notFoundFlag, history, prevContent } ) => {
3842 const [ toc , setToc ] = useState ( [ ] ) ;
3943 const [ comments , setComments ] = useState ( [ ] ) ;
@@ -127,6 +131,8 @@ const WikiContent = ({ author, DocTitle, content, notFoundFlag, history, prevCon
127131 const sanitizedHtml = DOMPurify . sanitize ( wrappedHtml , {
128132 ALLOWED_TAGS ,
129133 ALLOWED_ATTR ,
134+ FORBID_TAGS ,
135+ FORBID_ATTR ,
130136 } ) ;
131137
132138 return {
@@ -237,6 +243,8 @@ const WikiContent = ({ author, DocTitle, content, notFoundFlag, history, prevCon
237243 __html : DOMPurify . sanitize ( section . subtitle , {
238244 ALLOWED_TAGS ,
239245 ALLOWED_ATTR ,
246+ FORBID_TAGS ,
247+ FORBID_ATTR ,
240248 } ) ,
241249 } }
242250 > </ span >
@@ -270,6 +278,8 @@ const WikiContent = ({ author, DocTitle, content, notFoundFlag, history, prevCon
270278 __html : DOMPurify . sanitize ( htmlContent , {
271279 ALLOWED_TAGS ,
272280 ALLOWED_ATTR ,
281+ FORBID_TAGS ,
282+ FORBID_ATTR ,
273283 } ) ,
274284 } }
275285 > </ div >
@@ -293,6 +303,8 @@ const WikiContent = ({ author, DocTitle, content, notFoundFlag, history, prevCon
293303 __html : DOMPurify . sanitize ( comment , {
294304 ALLOWED_TAGS ,
295305 ALLOWED_ATTR ,
306+ FORBID_TAGS ,
307+ FORBID_ATTR ,
296308 } ) ,
297309 } }
298310 > </ span >
0 commit comments