feat(web): HTML sanitization#680
Open
hejsztynx wants to merge 8 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces automatic HTML sanitization for the web implementation to reduce XSS/paste-attack risk, and tightens/sanitizes custom <mention> attributes passed through the web input APIs.
Changes:
- Add a DOMPurify-backed sanitizer utility plus mention-attribute sanitization + runtime warnings for non‑
data-*custom attributes. - Sanitize HTML at major web input/output boundaries for TipTap (defaultValue/setValue/paste and getHTML/onChangeHtml).
- Update docs, example usage, and an E2E link test to align with the new sanitization behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/web/sanitization/htmlSanitizer.ts | Introduces sanitizeHtml, mention attribute sanitization, and attribute warning helper. |
| src/web/normalization/tiptapHtmlNormalizer.ts | Applies sanitization to TipTap HTML ingress/egress normalization. |
| src/web/EnrichedTextInput.tsx | Sanitizes/warns on mention attributes before inserting a mention. |
| src/web/tests/mentionSanitization.test.ts | Adds unit tests for mention attribute sanitization and sanitizer behavior. |
| docs/WEB.md | Updates web docs to describe automatic sanitization and mention attribute guidance. |
| docs/INPUT_API_REFERENCE.md | Documents 'default' mention style fallback behavior. |
| apps/example-web/src/App.tsx | Updates example mention attributes to use data-*. |
| .playwright/tests/links.spec.ts | Adjusts link copy/paste test data to a sanitizer-friendly URL. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
EnrichedTextInputandEnrichedTextdata-prefix, we print a runtime warning that it might get stripped by a sanitizer'default'mention style functionality wasn't documentedmentionattributes:id,textandindicator- now it allows every custom attributeTest Plan
Try to create a mention with an illegal HTML attribute, eg.
onClick. It should be stripped and a suitable console warning should be visible.Compatibility
Checklist