fix(web): canonical mention attributes are preserved with custom sanitizationConfig - #733
Merged
hejsztynx merged 2 commits intoJul 30, 2026
Conversation
…Regex is provided
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a web sanitization edge case where providing a custom sanitizationConfig.linkRegex caused DOMPurify to incorrectly treat whitelisted <mention> attributes (text, indicator) as URI-bearing attributes, resulting in those attributes being stripped. It updates the sanitization configuration so those canonical mention attributes are preserved even when a custom URI allowlist regex is used, and adds a regression test.
Changes:
- Update DOMPurify configuration to treat mention’s canonical attributes as URI-safe when
ALLOWED_URI_REGEXPis customized. - Thread sanitization configuration through web HTML normalization via a getter to ensure the latest config is used at normalization time.
- Add a regression test covering mention attribute preservation with a custom
linkRegex.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/web/useOnChangeHtml.ts | Switches from passing a static sanitization config to passing a getter into HTML normalization. |
| src/web/sanitization/htmlSanitizer.ts | Adds ADD_URI_SAFE_ATTR for mention canonical attributes to prevent URI-regex checks from stripping them. |
| src/web/normalization/tiptapHtmlNormalizer.ts | Updates normalization to call a sanitization-config getter before sanitizing. |
| src/web/EnrichedTextInput.tsx | Updates call sites to pass a sanitization-config getter into on-change normalization and imperative getHTML(). |
| src/web/tests/sanitization.test.ts | Adds regression coverage to ensure <mention> attributes survive when a custom linkRegex is provided. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
exploIF
approved these changes
Jul 30, 2026
szydlovsky
approved these changes
Jul 30, 2026
hejsztynx
deleted the
@ksienkiewicz/fix-web-sanitization-linkregex-strips-mention-attrs
branch
July 30, 2026 09:19
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
When
linkRegexinsanitizationConfigwas provided,DOMPurifytested the attributes whitelisted withADD_ATTR(in our casetextandindicator) against the URI regex. Now thetextandindicatorvalues are not tested this way. Added relevant regression tests.Test Plan
On the web example app, add a
mentionand look at the HTML outputCompatibility
Checklist