gpt4 book ai didi

python - jinja2(Flask)中是否默认自动转义?

转载 作者:行者123 更新时间:2023-11-30 22:27:22 24 4
gpt4 key购买 nike

我正在研究一些网站中的一些安全错误,想知道 jinja2 是否默认启用自动转义。根据 Jinja 文档( http://jinja.pocoo.org/docs/2.9/faq/#why-is-autoescaping-not-the-default ),它没有,但是当我在新系统上测试该应用程序时,它已启用(我可能不小心这样做了,但不确定。

有人能解释一下吗?

最佳答案

根据flask documentation :

除非定制,Jinja2 由 Flask 配置如下:

autoescaping is enabled for all templates ending in .html, .htm, .xml as well as .xhtml when using render_template().

另外:

autoescaping is enabled for all strings when using render_template_string().

最后:

a template has the ability to opt in/out autoescaping with the {% autoescape %} tag.

因此,虽然 jinja 默认情况下可能不会自动转义,但 flask 默认情况下会启用 Jinja 的自动转义。

关于python - jinja2(Flask)中是否默认自动转义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46944596/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com