Skip to content

feat(htmlSanitizer): add allowedTags configuration for safe custom HTML elements - #726

Closed
rupesh-kumar-sah wants to merge 1 commit into
Stellar-split:mainfrom
rupesh-kumar-sah:feat/issue-696-html-sanitizer-allowed-tags
Closed

rupesh-kumar-sah wants to merge 1 commit into
Stellar-split:mainfrom
rupesh-kumar-sah:feat/issue-696-html-sanitizer-allowed-tags

Conversation

@rupesh-kumar-sah

Copy link
Copy Markdown

Summary of Changes

Resolves #696

This PR adds configurable allowedTags support to htmlSanitizer:

  1. Allowlist Merging:
    • sanitizeHtml(dirty, options?: SanitizeOptions) accepts allowedTags: string[], which merges with DEFAULT_ALLOWED_TAGS rather than replacing it.
  2. Dangerous Attribute Sanitization:
    • Custom allowed tags (e.g. <mark>, <kbd>, <abbr>) are properly sanitized for dangerous attributes (event handlers like on* and javascript: URLs are stripped).
  3. Blocklist Enforcement:
    • Attempting to configure dangerous tags (script, iframe, object, form, etc.) throws a SanitizerConfigurationError.
  4. Verification:
    • Comprehensive test suite added in src/__tests__/htmlSanitizer.test.ts (8/8 tests green).
    • Typechecking clean via tsc --noEmit.

@vercel

vercel Bot commented Sep 17, 2026

Copy link
Copy Markdown

@rupesh-kumar-sah is attempting to deploy a commit to the kingsman-99's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

htmlSanitizer: Add allowedTags configuration for safe custom HTML elements

2 participants