JSONP callback validator.

Overview

JsonpCallbackValidator

Build Status Total Downloads Latest Stable Version

JsonpCallbackValidator allows you to validate a JSONP callback in order to prevent XSS attacks.

Usage

$validator = new \JsonpCallbackValidator();

$validator->validate('JSONP.callback');
// returns `true`

$validator->validate('(function xss(x){evil()})');
// returns `false`

Or as a static method:

\JsonpCallbackValidator::validate('JSONP.callback');
// returns `true`

\JsonpCallbackValidator::validate('(function xss(x){evil()})');
// returns `false`

Installation

The recommended way to install JsonpCallbackValidator is through Composer:

$ composer require willdurand/jsonp-callback-validator

Unit Tests

Setup the test suite using Composer:

$ composer install

Run it using PHPUnit:

$ ./vendor/bin/phpunit

Contributing

See CONTRIBUTING file.

Credits

License

JsonpCallbackValidator is released under the MIT License. See the bundled LICENSE file for details.

You might also like...
 Laravel Dutch Phone Number Validator
Laravel Dutch Phone Number Validator

Laravel Dutch Phone Number Validator Validate if the given phone number is a valid Dutch phone number Table of Contents Installation Usage Translation

A simple validator package to check if the given zipcode has a valid Dutch zipcode format
A simple validator package to check if the given zipcode has a valid Dutch zipcode format

Laravel Dutch Zipcode Validator A simple validator package to check if the given zipcode has a valid Dutch zipcode format Table of Contents Installati

Disposable email address validator for Laravel

Laravel Disposable Email Adds a validator to Laravel for checking whether a given email address isn't originating from disposable email services such

EmailValidator - PHP Email address validator

EmailValidator A library for validating emails against several RFC. Supported RFCs This library aims to support RFCs: 5321, 5322, 6530, 6531, 6532, 10

MetaYaml - A powerful schema validator

MetaYaml A [put your file type here] schema validator using [put another file type here] files. At the moment, file type can be Json, Yaml, or XML. It

One time password generator, validator, and qrcode generator that has no web dependencies (self-contained) in PHP
One time password generator, validator, and qrcode generator that has no web dependencies (self-contained) in PHP

otp-thing One time password generator, validator, and qrcode generator that has no web dependencies (self-contained) in PHP Introduction This started

PHP Email address validator - A library for validating emails against several RFC.

EmailValidator A library for validating emails against several RFC. Supported RFCs This library aims to support RFCs: 5321, 5322, 6530, 6531, 6532, 10

This Validate Class is for those who are looking for a validator that returns a code for every each error (Laravel/Api)
This Validate Class is for those who are looking for a validator that returns a code for every each error (Laravel/Api)

Validator-Class This Validate Class is for those who are looking for a validator that returns a code for every each error (Laravel/Api) Requirements A

Modern PHP validator on steroids for validating forms and/or array's.

Modern PHP Validator - Standalone Validation on Steroids Introduction Head first example Installation Adding fields for validation Execute validation

Comments
  • Allows to call the `validate` method statically

    Allows to call the `validate` method statically

    As the validator implementation might not vary, I find it cumbersome to have to instantiate an object for the validator.

    In addition to being easier to write, this PR eliminates initialization of the same array several times if the validator is used several times.

    opened by GromNaN 9
  • Test enhancement

    Test enhancement

    Changed log

    • Using the psr-4 autoload because psr-o is deprecated.
    • Using the PHPUnit namespace to be compatible with latest stable PHPUnit version.
    • Let hhvm version be failed because it seems this version will be failed in Travis CI build.
    opened by peter279k 1
  • Improve the composer instructions in the readme

    Improve the composer instructions in the readme

    Using "composer require" means that it will automatically choose a semver constraint, and that it will also take care of not breaking the composer.json file (safer than manual update)

    opened by stof 1
Releases(v2.0.0)
  • v2.0.0(Jan 30, 2022)

    👋 Hey, it's been a long time, right? Almost 8 years. I merged a PR to validate the callback type recently. I don't think this is a BC break but this library has been super stable for so long that I didn't want to take any risk. That's why I just released 2.0.0 and not 1.2.0. Let me know if everything works with PHP 8.x these days.

    Cheers, Will


    What's Changed

    • Added: validate callback type by @abienvenu in https://github.com/willdurand/JsonpCallbackValidator/pull/10
    • Fixed: switch to github actions by @willdurand in https://github.com/willdurand/JsonpCallbackValidator/pull/11

    New Contributors

    • @Nyholm made their first contribution in https://github.com/willdurand/JsonpCallbackValidator/pull/6
    • @willdurand made their first contribution in https://github.com/willdurand/JsonpCallbackValidator/pull/11
    • @abienvenu made their first contribution in https://github.com/willdurand/JsonpCallbackValidator/pull/10

    Full Changelog:

    See: https://github.com/willdurand/JsonpCallbackValidator/compare/v1.1.0...v2.0.0

    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Jan 21, 2014)

  • v1.0.0(Oct 21, 2013)

Owner
William Durand
William Durand
laminas-password-validator provides a validator for character-set based input validation.

laminas-password-validator laminas-password-validator provides a validator for character-set based input validation. Installation composer require pra

null 1 Mar 8, 2022
:envelope: E-Mail Address Validator (syntax, dns, trash, typo)

✉️ E-Mail Address Validator for PHP Warning The best way to validate an e-mail address is still to send a duplicate opt-in-mail, when the user clicks

Lars Moelleken 41 Dec 25, 2022
A powerful schema validator!

MetaYaml A [put your file type here] schema validator using [put another file type here] files. At the moment, file type can be Json, Yaml, or XML. It

Romaric Drigon 100 Sep 28, 2022
laravel-model-validator

laravel-model-validator This is a simple validator. The validator can be created by command. The validator has all common table column constraint, eg:

null 6 May 22, 2022
OpenAPI(v3) Validators for Symfony http-foundation, using `league/openapi-psr7-validator` and `symfony/psr-http-message-bridge`.

openapi-http-foundation-validator OpenAPI(v3) Validators for Symfony http-foundation, using league/openapi-psr7-validator and symfony/psr-http-message

n1215 2 Nov 19, 2021
This is a simple url bot validator made with laravel and react

?? This is a simple URL validator. Used Technologies React - Javascript framework Laravel - PHP framework Mysql - Relational database Installation Ins

Vanderson Telema 1 Oct 27, 2021
Laravel Disposable Email Validator

Laravel Disposable Email Validator Prevent users from registrering with a disposable email addresses! Table of Contents Installation Usage Translation

Tim Wassenburg 2 Oct 12, 2022
Laravel Common Password Validator

laravel-common-password-validator Laravel Common Password Validator An optimized and secure validator to check if a given password is too common. By d

WedgeHR 1 Nov 6, 2021
Argentinian CUIT and CUIL Validator

CUIT/CUIL Validator Argentinian CUIT and CUIL Rules for laravel validation Installation $ composer require iutrace/laravel-cuit-validator Usage Exampl

iutrace 6 Sep 20, 2022
Custom Laravel Validator for combined unique indexes

unique_with Validator Rule For Laravel This package contains a variant of the validateUnique rule for Laravel, that allows for validation of multi-col

Felix Kiss 383 Oct 18, 2022