用于 XSS 过滤的 Python 库? [英] Python library for XSS filtering?

查看:28
本文介绍了用于 XSS 过滤的 Python 库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个好的、积极维护的 python 库可用于过滤恶意输入,例如 XSS?

Is there a good, actively maintained python library available for filtering malicious input such as XSS?

推荐答案

如果您使用的是 Web 框架和像 Jinja2 这样的模板引擎,那么模板引擎或框架可能会为此内置一些东西.

If you are using a web framework and a template engine like Jinja2 there is a chance that the template engine or the framework has something built in just for that.

cgi 模块中有一些东西可以帮助您:

There is something in the cgi module that can help you:

cgi.escape('这里的恶意代码'),参见:http://docs.python.org/library/cgi.html#cgi.escape

还有 Jinja2 提供转义:

Also Jinja2 provides escaping:

from jinja2 import utils
str(utils.escape('malicious code here'))

这篇关于用于 XSS 过滤的 Python 库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆