0
0
Expressframework~10 mins

Sanitization methods in Express - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to sanitize the input by trimming whitespace.

Express
const sanitizedInput = req.body.username.[1]();
Drag options to blanks, or click blank then click option'
Anormalize
Bescape
CtoLowerCase
Dtrim
Attempts:
3 left
💡 Hint
Common Mistakes
Using escape() instead of trim() removes HTML characters, not spaces.
normalize() changes Unicode forms, not whitespace.
toLowerCase() changes case, not whitespace.
2fill in blank
medium

Complete the code to escape HTML characters in the input.

Express
const safeInput = req.body.comment.[1]();
Drag options to blanks, or click blank then click option'
Aescape
Btrim
CtoUpperCase
Dslice
Attempts:
3 left
💡 Hint
Common Mistakes
Using trim() only removes spaces, not HTML characters.
toUpperCase() changes letter case, not safety.
slice() extracts parts of strings, no sanitization.
3fill in blank
hard

Fix the error in the sanitization chain to properly normalize and trim the input.

Express
const cleanInput = req.body.email.[1]().trim();
Drag options to blanks, or click blank then click option'
AtoLowerCase
Bescape
Cnormalize
Dslice
Attempts:
3 left
💡 Hint
Common Mistakes
Using escape() does not normalize Unicode.
toLowerCase() changes case but not normalization.
slice() does not sanitize or normalize.
4fill in blank
hard

Fill both blanks to sanitize input by trimming and escaping.

Express
const safeText = req.body.text.[1]().[2]();
Drag options to blanks, or click blank then click option'
Atrim
Bescape
CtoLowerCase
Dnormalize
Attempts:
3 left
💡 Hint
Common Mistakes
Reversing the order can cause issues.
Using toLowerCase does not sanitize input.
Normalize is not needed here.
5fill in blank
hard

Fill all three blanks to sanitize input by normalizing, trimming, and escaping.

Express
const finalInput = req.body.input.[1]().[2]().[3]();
Drag options to blanks, or click blank then click option'
Anormalize
Btrim
Cescape
DtoLowerCase
Attempts:
3 left
💡 Hint
Common Mistakes
Changing order can cause incorrect sanitization.
Using toLowerCase does not sanitize input.
Skipping normalization can cause Unicode issues.