innerHTML

Ethan KIM·2022년 7월 11일

HTML

목록 보기
1/1

innerHTML 은 html 컨텐츠를 js 에서 손쉽게 다룰 수 있게 하는 명령어 인데,
이게 작동 원리가 replace임.

기존에 있던 컨텐츠(existing contents) 를 새로운 컨텐츠로(new content) replace.

근데 여기서 보안상 문제가 발생 할 수 있는데,

This is a security risk if the string to be inserted might contain potentially malicious content. When inserting user-supplied data you should always consider using Element.SetHTML() instead, in order to sanitize the content before it is inserted.

새로운 컨텐츠로 무조건 적으로 replace 될때, 각종 malicious content가 함께 삽입 될 수 있음.
그래서 꼭 Element.SetHTML()로 하는게 나음 => sanitize하기 위해.

profile
좋아하는것만 함

0개의 댓글