escape
Problem
You need to safely insert user-provided text into HTML — converting &, <, >, ", and ' to their HTML entities.
Solution
Use escape(value) to HTML-encode a string.
ts
import { escape } from '@vielzeug/arsenal';
escape('<script>alert("xss")</script>');
// '<script>alert("xss")</script>'
escape('Alice & Bob'); // 'Alice & Bob'Pitfalls
- Only escapes the five HTML-special characters — does not encode all Unicode characters.