Laravel清理中间件无法正常工作

Laravel清理中间件无法正常工作

问题描述:

I'm using a sanitizing package. this package is for laravel and sanitizes data for security and XSS attacks and has a helper function: clean($data) , $data can be a string or array.

I build a middleware to purify data for every requet that is comming.

handle() function for this middleware is:

    public function handle( $request, Closure $next)
    {
        $request = clean( $request->all() );

        return $next( $request );
    }

this function cleans and purifies every data thai is comming to my app.

I know I'm making a big mistake and misunderstanding!

what I have done wrong?

我正在使用一个清理包。 这个包用于laravel并清理数据以进行安全性和XSS攻击。 辅助函数:clean($ data),$ data可以是字符串或数组。 p>

我构建了一个中间件来为每个提交的requet净化数据。 p>

此中间件的handle()函数是: p> \ n

 公共函数句柄($ request,Closure $ next)
 {
 $ request = clean($ request-> all()); 
 
返回$ next($ request)  ); 
} 
  code>  pre> 
 
 

此函数清除并净化我的应用程序中的每个数据。 p>

我知道我 我犯了一个大错误和误解! p>

我做错了什么? p> div>

Your clean() function should return an instance of Illuminate\Http\Request because that's what the $next Closure needs to proceed. Perhaps your clean() function is returning a different type such as a string or an array.