voku / anti-xss-twig
用于XSS保护的Twig扩展。
3.0.1
2018-10-27 23:50 UTC
Requires
- php: >=7.0.0
- twig/twig: ^1.26|~2.0
- voku/anti-xss: ~4.1
Requires (Dev)
- phpunit/phpunit: ~6.0
This package is auto-updated.
Last update: 2024-09-15 16:09:50 UTC
README
AntiXSS for Twig
描述
一个Twig扩展,用于voku/anti-xss。
当前支持的Twig功能有
-
标签(推荐)
{% xss_clean %} <foo>bar</foo> {% end_xss_clean %}
-
函数
{{ xss_clean(' <foo>bar</foo>') }}
-
过滤器
{{ '<foo>bar</foo>' | xss_clean }}
安装
- 在您的项目中安装并使用composer。
- 通过composer要求此包
composer require voku/anti-xss-twig
使用
首先将扩展注册到Twig
use voku\helper\AntiXSS; use voku\twig\AntiXssExtension; $twig = new Twig_Environment($loader); $antiXss = new AntiXSS(); $twig->addExtension(new AntiXssExtension($antiXss));
然后在模板中使用它
{% xss_clean %} <foo>bar</foo> {% end_xss_clean %}
$twig->addExtension(new AntiXssExtension($antiXss));
历史记录
查看CHANGELOG以获取变更的完整历史。