SESK: Stuff Everyone Should Know · sesk.info/tech-xss-context-encoding
Why must XSS output encoding match the browser context?
Browsers parse HTML, JavaScript, URLs, and CSS differently.
- Every context uses SQL
- Encoding changes screen size
- Each context has different syntax ✔
Why: An encoder safe for ordinary HTML text may be wrong inside JavaScript, CSS, a URL, or an attribute. Context-aware encoding stops untrusted text from becoming executable syntax.
Huh, didn't know that: When users intentionally author HTML, sanitization is needed instead of displaying it as encoded text.
HTML and JavaScript argued because each wanted its own escape plan.
Like this card?
References
Answer: Each context has different syntax. An encoder safe for ordinary HTML text may be wrong inside JavaScript, CSS, a URL, or an attribute. Context-aware encoding stops untrusted text from becoming executable syntax.
- OWASP Cross Site Scripting Prevention Cheat Sheet cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html
browsers parse HTML, JS, URLs, and CSS differently
Checked 2026-10-10.
Think this answer is wrong? Tap "Challenge this answer" on the card in the game and tell us why.
More stuff everyone should know
That's stuff everyone should know.