New Sanitizing Middleware0:00
5.4 contains a couple new middleware. So let's go into HTTP, Kernel, and you'll see right down here, TrimStrings and ConvertEmptyStringsToNull. These are essentially sanitizing middleware that are actually very, very useful. We generally have to write this logic on our own. Let me show you. I'm going to go to my routes/web.php file, and you'll see that I've set up a couple quick dummy routes. One to display a form, and then one to process the form, and all that does is it just returns the form data.
Testing Input Trimming0:24
One to display a form, and then one to process the form, and all that does is it just returns the form data. Okay. So we're going to go to form.blade.php, and you'll see here I've set up a little bootstrap form. We have our csrf field, we have a section for your name, a section for the comment, and a submit button. You can't get any more basic than that. So if we now go to Chrome, I'm going to type in gibberish here, but I'm going to add lots of spaces at the end, and the exact same thing here. Well, if I submit it, you'll see that those are now trimmed off, and they were not in
