Code Explainers

Code explainers tagged #xss-prevention

python
import bleach
 
ALLOWED_TAGS = [
    "a", "b", "strong", "i", "em", "u",

Sanitizing user HTML with bleach

sanitization xss-prevention whitelisting
Intermediate 5 steps
typescript
import sanitizeHtml from "sanitize-html";
 
interface RichTextOptions {
  allowImages?: boolean;

Building a configurable HTML sanitizer allowlist

sanitization xss-prevention allowlist
Intermediate 7 steps
javascript
const ESCAPE_MAP = {
  '&': '&',
  '<': '&lt;',
  '>': '&gt;',

Escaping HTML before injecting user content

xss-prevention escaping dom
Intermediate 6 steps