Laravel Validation And User Input Sanitization To Prevent XSS Exploits

Submitted by azazqadir - 11 months ago

XSS Exploit is a well-known vulnerability in a web app whereby an attacker can inject client-side code into a web page. This is can be done through user input areas such as search boxes, comments, posts, etc. Source:

// Display All Tasks 
Route::get('/', function () {
   $tasks = Task::orderBy('created_at', 'asc')->get();
   return view('tasks', [
       'tasks' => $tasks
// Add A New Task
Route::post('/task', function (Request $request) {
   $task = new Task;
   $task->name = $request->name;
   return redirect('/');
// Delete An Existing Task
Route::delete('/task/{id}', function ($id) {
   return redirect('/');
comments powered by Disqus

Ads cover the costs of maintaining Laravel-tricks