search

Home  >  Q&A  >  body text

javascript - 页面前端输入框验证js代码,防止xss

demo

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

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

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

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

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

reply all(1)I'll reply

  • PHPz

    PHPz2017-04-10 14:50:22

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

    reply
    0
  • Cancelreply