Complete the code to sanitize the input by trimming whitespace.
const sanitizedInput = req.body.username.[1]();The trim() method removes whitespace from both ends of a string, which is a basic sanitization step.
Complete the code to escape HTML characters in the input.
const safeInput = req.body.comment.[1]();The escape() method converts HTML characters to safe entities, preventing injection attacks.
Fix the error in the sanitization chain to properly normalize and trim the input.
const cleanInput = req.body.email.[1]().trim();The normalize() method standardizes Unicode characters, which is important before trimming.
Fill both blanks to sanitize input by trimming and escaping.
const safeText = req.body.text.[1]().[2]();
First trim removes spaces, then escape converts HTML characters to safe entities.
Fill all three blanks to sanitize input by normalizing, trimming, and escaping.
const finalInput = req.body.input.[1]().[2]().[3]();
Normalize Unicode first, then trim spaces, and finally escape HTML characters for safety.