简体   繁体   中英

Approach XSS prevention on Html page using javascript

如何使用javascript(而非jsp页面)转义表单的文本框内容以避免xss。提交表单时,必须在页面上正确地重新放置它。

使用document.appendChilddocument.createTextNode和friends而不是接受原始HTML的属性(例如innerHTML )将文本插入文档中。

"Insert the text into the document using document.appendChild, document.createTextNode and friends instead of a property (such as innerHTML) that accepts raw HTML."

as Quentin says, or, using an existing textbox, use the value property:

textObject.value="value"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM