Input sanitization using the HTMLSanitizer library
There are other open source libraries out there that do a good job of sanitizing input, and one of them is HTMLSanitizer
.
In this recipe, you will learn how to sanitize input using the HTMLSanitizer
third-party library.
Getting ready
Using Visual Studio Code, open the sample Online Banking app folder at \Chapter01\input-sanitization-htmlsanitizer\before\OnlineBankingApp
.
How to do it…
Let's take a look at the steps for this recipe:
- Launch Visual Studio Code and open the starting exercise folder by typing the following command:
code .
- Navigate to Terminal | New Terminal in the menu or simply press Ctrl + Shift + ' in Visual Studio Code.
- Type the following command to install the
HtmlSanitizer
package in your project:dotnet add package HtmlSanitizer
- Open the
Models/FundTransfer.cs
file and add a reference toGanss.XSS
, which is theHtmlSanitizer
namespace:using Ganss.XSS;
- Modify...