Repository navigation
fix(muya): align normalizePastedHTML link unlinking with muyajs - #4550
Merged
Merged
Conversation
Two divergences in the `<a>`-unlinking pass of normalizePastedHTML: - The guard was `href === text` without muyajs's `URL_REG.test(href)`, so any link whose visible text happened to equal its href — even a non-URL like `<a href="foo">foo</a>` — was stripped to a bare span. Restore the URL_REG guard so only real bare-URL links are unlinked. - The fallback span set `innerHTML = text` raw; muyajs escapes + sanitizes via `sanitize(text, PREVIEW_DOMPURIFY_CONFIG, true)`. Match it so a stray angle bracket in the link text can't re-enter as live markup. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Jocs
force-pushed
the
fix/clipboard-normalize-html
branch
from
June 18, 2026 07:55
ed38455 to
15849b8
Compare
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.
Two divergences in the
<a>-unlinking pass ofnormalizePastedHTML(
packages/muya/src/utils/paste.ts) versus legacy muyajs(
pasteCtrl.normalizePastedHTML):URL_REGguard. muyajs unlinks a bare URL only whenURL_REG.test(href) && href === text. muya checked justhref === text, soany link whose visible text happened to equal its href — even a non-URL like
<a href="foo">foo</a>— was stripped to a bare span. Restore the URL guardso only real bare-URL links are unlinked.
span.innerHTML = textraw; muyajs escapes + sanitizes viasanitize(text, PREVIEW_DOMPURIFY_CONFIG, true). Match it so a stray anglebracket in the link text can't re-enter as live markup.
Tests
New
src/utils/__tests__/normalizePastedHtml.spec.ts(RED→GREEN verified):non-URL link preserved, differing-text link preserved, bare-URL link unlinked to
an escaped span when offline. 141/141 utils specs green; typecheck clean.
Independent of the clipboard paste stack (touches only
utils/paste.ts).🤖 Generated with Claude Code