feat(web): HTML sanitization - #680
Merged
Merged
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.
hejsztynx
marked this pull request as ready for review
July 6, 2026 12:17
kacperzolkiewski
approved these changes
Jul 8, 2026
exploIF
requested changes
Jul 17, 2026
exploIF
left a comment
Collaborator
There was a problem hiding this comment.
In general looks good. However custom domains support is a blocker from my perspective. Happy to discuss potential solutions, but we should at least give an option for the users
hejsztynx
marked this pull request as draft
July 22, 2026 12:30
# Summary Both components `EnrichedText` and `EnrichedTextInput` are using DOM - `DOMPurify`, `DOMParser`, `TipTap`. An attempt of rendering them in a non-browser environment, e.g. in SSR applications, would result in a crash. Only `DOMParser` availability check was present, but it was silent. Now we check for the browser environment before any other component logic and throw a proper error. Documentation was also updated, to explicitly point the client-only nature of the components. ## Compatibility | OS | Implemented | | ------- | :---------: | | iOS | ❌ | | Android | ❌ | | Web | ✅ | ## Checklist - [x] E2E tests are passing - [ ] Required E2E tests have been added (if applicable)
hejsztynx
marked this pull request as ready for review
July 27, 2026 11:06
exploIF
approved these changes
Jul 27, 2026
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 attributesanitizationConfig, currently with onlylinkRegexfield, allowing to persist custom links which would be otherwise stripped by the sanitizerTest 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