voku / anti-xss-twig
Twig extension for XSS protection.
Installs: 6 053
Dependents: 0
Suggesters: 0
Security: 0
Stars: 11
Watchers: 3
Forks: 1
Open Issues: 3
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-11-15 16:29:34 UTC
README
AntiXSS for Twig
Description
A Twig extension for voku/anti-xss.
Currently supported Twig features are:
-
Tag (recommended)
{% xss_clean %} <foo>bar</foo> {% end_xss_clean %}
-
Function
{{ xss_clean(' <foo>bar</foo>') }}
-
Filter
{{ '<foo>bar</foo>' | xss_clean }}
Installation
- Install and use composer in your project.
- Require this package via composer:
composer require voku/anti-xss-twig
Usage
First register the extension with Twig:
use voku\helper\AntiXSS; use voku\twig\AntiXssExtension; $twig = new Twig_Environment($loader); $antiXss = new AntiXSS(); $twig->addExtension(new AntiXssExtension($antiXss));
Then use it in your templates:
{% xss_clean %} <foo>bar</foo> {% end_xss_clean %}
$twig->addExtension(new AntiXssExtension($antiXss));
History
See CHANGELOG for the full history of changes.