Output encoding
Converting data into a safe form for the exact context it is written into, such as HTML entity encoding for element text or JavaScript string escaping inside a script, so the interpreter treats it as data. Encoding for the wrong context leaves the injection open.
- Also called
- output escaping · contextual output encoding · contextual encoding
Covered in
Practice: XSS lab: Render a model’s answer as text instead of active markup · HTML sanitization lab: Configure a sanitizer for user comments