javascript - 页面前端输入框验证js代码,防止xss
PHP中文网
PHP中文网 2017-04-10 14:48:22
0
1
431

demo

类似这种简单的输入框,输入不限制特殊字符输入的情况下,怎么去检测处理类似这种问题。

直接检测 "<script>" 字符串来 判断处理么?

这方面问题有什么比较好的处理方案么?

就这么如下处理的话,在前端安全方面还有哪些很欠考虑的点呢?

var html = html.replace(/</g, "&lt;").replace(/>/g, "&gt;");
PHP中文网
PHP中文网

认证0级讲师

Antworte allen(1)
PHPzhong

https://github.com/leizongmin/js-xss

Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage