Learn

Sanitize Untrusted Content

Apply Cuddler's default safety posture when rendering content that may contain unsafe HTML, scripts, or risky links.

Safety path

How untrusted content should move through rendering

Sanitization is part of the render contract for untrusted content, not a last-minute cleanup pass.

1Validate data

Start from the correct Data Schema before rendering logic enters the picture.

2Validate template

Check the Template Schema separately so the render contract is explicit.

3Render with strict sanitization

Escape text, strip unsafe tags, and treat relaxed behavior as exceptional.

4Allow only what is needed

Keep URI schemes and external-asset behavior as narrow as the use case allows.

5Review warnings and trace

Use warnings and trace output to understand what changed and why.

Strict by default keeps the trust boundary visible and predictable.

When the content is not fully trusted, treat sanitization as part of the rendering contract, not as an optional cleanup step.

  1. Validate the data first with the correct Data Schema.
  2. Validate the template second with the matching Template Schema.
  3. Render with strict sanitization as the default.
  4. Allow only the external asset behavior you actually need.
  5. Review warnings and trace output when content is removed or transformed.

Safety Checklist

  • Escape all text nodes.
  • Remove script-like and embed-like tags that do not belong in the rendered output.
  • Strip event handlers and unsafe URI schemes.
  • Treat relaxed rendering as an explicit decision, not a default.

When To Relax

Only relax sanitization when the content source is trusted, the output contract is explicit, and the surrounding product design still makes the trust boundary obvious to the user.