Performance: XSS prevention in templates
HIGH IMPACT
This affects page security and rendering speed by controlling how user input is handled and displayed in templates.
{{ user_input }}{% autoescape off %}{{ user_input }}{% endautoescape %}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Autoescape enabled (default) | Minimal, safe DOM nodes | 0 reflows from scripts | Normal paint cost | [OK] Good |
| Autoescape disabled with raw input | Potentially many DOM changes from scripts | Multiple reflows possible | High paint cost due to layout shifts | [X] Bad |
| Using |safe filter on untrusted input | Uncontrolled DOM manipulations | Multiple reflows and repaints | High paint cost and CLS risk | [X] Bad |
| Explicit escaping with |escape filter | Safe DOM nodes | 0 reflows from scripts | Normal paint cost | [OK] Good |