Skip to content

Instantly share code, notes, and snippets.

@ctf0
Last active November 8, 2020 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctf0/745eaf513fde1bc8d82856e31e1eb7b0 to your computer and use it in GitHub Desktop.
Save ctf0/745eaf513fde1bc8d82856e31e1eb7b0 to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Middleware\External;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Foundation\Http\Middleware\TransformsRequest;
class CleanEvilInput extends TransformsRequest
{
/**
* The attributes that should not be edited.
*
* @var array
*/
protected $except = [];
/**
* Transform the given value.
*
* @param string $key
* @param mixed $value
*
* @return mixed
*/
protected function transform($key, $value)
{
if (in_array($key, $this->except, true)) {
return $value;
}
return Binput::clean($value, true, true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment