JsonpCallbackValidator
, (*1)
JsonpCallbackValidator allows you to validate a JSONP callback in order
to prevent XSS attacks., (*2)
Usage
$validator = new \JsonpCallbackValidator();
$validator->validate("JSONP.callback");
// returns `true`
$validator->validate("(function xss(x){evil()})");
// returns `false`
Or as a static method:, (*3)
\JsonpCallbackValidator::validate("JSONP.callback");
// returns `true`
\JsonpCallbackValidator::validate("(function xss(x){evil()})");
// returns `false`
Installation
The recommended way to install JsonpCallbackValidator is through
Composer:, (*4)
$ composer require willdurand/jsonp-callback-validator
Unit Tests
Setup the test suite using Composer:, (*5)
$ composer install
Run it using PHPUnit:, (*6)
$ ./vendor/bin/simple-phpunit
Contributing
See CONTRIBUTING file., (*7)
Credits
License
JsonpCallbackValidator is released under the MIT License. See the bundled
LICENSE file for details., (*8)