https://github.com/voku/anti-xss-twig
AntiXSS for Twig
https://github.com/voku/anti-xss-twig
hacktoberfest html php php7 security xss
Last synced: 6 months ago
JSON representation
AntiXSS for Twig
- Host: GitHub
- URL: https://github.com/voku/anti-xss-twig
- Owner: voku
- License: mit
- Created: 2017-03-22T06:37:45.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T14:40:57.000Z (almost 2 years ago)
- Last Synced: 2024-04-14T09:07:44.577Z (over 1 year ago)
- Topics: hacktoberfest, html, php, php7, security, xss
- Language: PHP
- Homepage:
- Size: 15.6 KB
- Stars: 11
- Watchers: 3
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/voku/anti-xss-twig)
[](https://coveralls.io/github/voku/anti-xss-twig?branch=master)
[](https://scrutinizer-ci.com/g/voku/anti-xss-twig/?branch=master)
[](https://www.codacy.com/app/voku/anti-xss-twig?utm_source=github.com&utm_medium=referral&utm_content=voku/anti-xss-twig&utm_campaign=Badge_Grade)
[](https://insight.sensiolabs.com/projects/7841fd87-ea3e-4ce2-9be8-e0100fbc1c25)[](https://packagist.org/packages/voku/anti-xss-twig)
[](https://packagist.org/packages/voku/anti-xss-twig)
[](https://packagist.org/packages/voku/anti-xss-twig)
[](https://packagist.org/packages/voku/anti-xss-twig)# AntiXSS for Twig
## Description
A [Twig](http://twig.sensiolabs.org/) extension for [voku/anti-xss](https://github.com/voku/anti-xss).
Currently supported Twig features are:
* Tag (*recommended*)
* `{% xss_clean %} bar {% end_xss_clean %}`
* Function
* `{{ xss_clean(' bar') }}`
* Filter
* `{{ 'bar' | xss_clean }}`* [Installation](#installation)
* [Usage](#usage)
* [History](#history)## Installation
1. Install and use [composer](https://getcomposer.org/doc/00-intro.md) in your project.
2. Require this package via composer:```sh
composer require voku/anti-xss-twig
```## Usage
First register the extension with Twig:
```php
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 %} bar {% end_xss_clean %}
``````php
$twig->addExtension(new AntiXssExtension($antiXss));
```## History
See [CHANGELOG](CHANGELOG.md) for the full history of changes.