Laravel JSON Escape
Filter JSON response against XSS.
Install
composer require davidvandertuijn/laravel-json-escape
Usage
return response()->json_escape([
"text" => "<p>Hello World</p>"
]);
{"text":"Hello World"}
Exclude
return response()->json_escape([
"text" => "Hello World",
"html" => "<p>Hello World</p>"
], [
"html"
]);
{"text":"Hello World","html":"<p>Hello World</p>"}
References
HTTP Responses - Laravel - The PHP Framework For Web Artisans