I'm creating a middleware for XSS protection in Slim framework. Here is my code:
$input = $request->getParsedBody();
array_walk_recursive($input, function(&$input) {
$input = htmlspecialchars($input);
});
$request->merge($input); // Not able to merge $input into $request
return $next($request, $response, $next);
After sanitizing the request I wanted to merge into slim http request so that when I use $request->getParsedBody(), I should get the sanitize data.