Repository navigation
[INFRA-1243] fix: parse pasted editor HTML inertly - #10307
Conversation
Clipboard markup is now parsed with DOMParser instead of being assigned to an element of the page's document, so it cannot load or run anything while image-components are prepared for duplication.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 29 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
React Doctor found no new issues. 🎉 Reviewed by React Doctor for commit |
|
Linked to Plane Work Item(s) This comment was auto-generated by Plane |
sriramveeraghanta
left a comment
There was a problem hiding this comment.
LGTM. Only the text/plane-editor-html path changes, and external paste already went through ProseMirror's inert parser.
Clipboard markup is now parsed with DOMParser instead of being assigned to an element of the page's document, so it cannot load or run anything while image-components are prepared for duplication.
Clipboard markup is now parsed with DOMParser instead of being assigned to an element of the page's document, so it cannot load or run anything while image-components are prepared for duplication. (cherry picked from commit 143f247)
Description
processAssetDuplicationassigned clipboard HTML from the editor's custom clipboard type toinnerHTMLof an element created in the page's document, before ProseMirror parsed it. Markup in that element can load resources and run inline handlers even though it is never attached.It now parses the string with
new DOMParser().parseFromString(html, "text/html")and works on that inert document'sbody, ashelpers/parser.tsalready does. Input, output and the handler loop are unchanged.Type of Change
Screenshots and Media (if applicable)
Test Scenarios
packages/editor/src/helpers/__tests__/paste-asset.test.ts: handlers receive elements that do not belong to the page's document (fails without the fix), and the processed output for a normal image and for an http source is unchanged. Editor suite: 15 passed.Not run in a browser. Please check manually: copy and paste an image between two editors.
References
Created with Claude Code