Repository navigation
fix(core): only Studio's own preview pages get the editing port, and undo sets only safe attributes - #8057
Merged
Conversation
…undo sets only safe attributes restore-attributes now changes only class, style and the editor's timing, layout, audio and label data- attributes, and drops only data- ones; any other change answers applied: false and Studio reloads the preview. The editing agent hands its port over only when the page carries Studio's preview mark and not the another-site mark, so a page no Studio marked never offers it.
vanceingalls
approved these changes
Nov 17, 2026
vanceingalls
left a comment
Collaborator
There was a problem hiding this comment.
Approved at 8a0635a.
- What restore can set: a fixed set of 19 names, matched exactly (class, style and 17 named
data-*). Case and whitespace variants andon*handlers fall outside it and are refused. - What restore can remove: only that set plus
data-*. - When it refuses: the whole restore is refused before anything changes, and
gsapUndoRestorereloads the preview once, so there's no reload loop. - Port gate: the port goes only to a page carrying Studio's preview mark, the meta that
preview.tsstamps on pages it serves. A Studio page framed by another site gets theanother-sitemeta plus thesandbox allow-scriptsCSP fromcreateStudioApi, somarkedForStudiois false and it gets no port. - Test: the
fails without the fix:line is present.
Should-fix:
- Lazy images:
lazyPreviewImagesaddsloading="lazy"to images with a start time, and dropping it is now refused, so undo on any lazy image always reloads. Allow removingloading, or note the regression. - Handoff target: the port is still handed over with
postMessage(..., "*")toevent.source === parent, so the meta is the only gate. Pin the handoff to the iframe Studio created (or its origin) when convenient.
The preview server adds loading="lazy" to timed images and the saved file does not have it, so the restore now may drop loading; dropping it loads nothing new.
Collaborator
Author
|
Thanks. Both should-fixes:
|
vanceingalls
approved these changes
Nov 17, 2026
vanceingalls
left a comment
Collaborator
There was a problem hiding this comment.
Re-approved at 4932320. This covers my lazy-image should-fix: safeToDrop now also allows removing loading, so undo on a lazily loaded image applies in place. loading is still not settable, so nothing new can be added.
Contributor
Edit accuracy: accurate 267 (base branch 267), smooth 110 of thoseThe gate passes. Quarantined, measured but not gated (8)
Unstable (2)
|
vanceingalls
approved these changes
Nov 17, 2026
vanceingalls
left a comment
Collaborator
There was a problem hiding this comment.
Re-approved at 70e8eaf. This is a style-only change: one doc-comment line wrapped to fit the line limit.
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.
What
Two changes to the preview's editing channel, the message port a preview page hands its parent so Studio can read and edit the composition in place.
restore-attributesonly changes attributes on an allowlist. An undo applied in place may setclass,styleand the timing, layout, audio and labeldata-attributes Studio's editor writes (data-start,data-duration,data-track-index,data-volume,data-xand so on), and may drop those,loading, or any otherdata-attribute (the live page carries the preview's own markers and theloading="lazy"the preview server adds to timed images, which the saved file does not). Any other change, such as an event handler, a URL attribute (src,href,srcdoc,xlink:href,data-composition-src) orsandbox, makes the frame answerapplied: falseand change nothing; Studio then reloads the preview, as it does for every other restore it cannot apply in place. Attributes whose value is already what the file says are no longer set again, so an image's unchangedsrcis left alone.<meta name="hyperframes-studio-preview">, which the preview route already stamps on every page it serves, Desktop's included) and not the another-site mark. A page with no mark never gets the port.Why
Before this, a site that could frame a preview page and get the port could send
restore-attributeswith anonerrororsrcattribute and run script in the page's origin, which can read the project's files. The allowlist stops the attribute half; the positive mark stops a page that never asked for an editing parent from offering one.Related work
Follows #8009, which added
restore-attributes.How
packages/core/src/runtime/editing/restoreAttributes.ts: the plan now works out, per element, the attributes it would drop and the ones whose value it would change, and refuses the whole restore before touching anything when one is outside the allowlist.packages/core/src/studioPreviewMark.ts:markedForStudio(doc)is the Studio mark present and the another-site mark absent;installEditingAgentasks it instead of only checking the another-site mark.installMarkedEditingAgenthelper (editingAgent.test-helpers.ts) that adds the Studio mark, since that is now what a page needs to hand over the port.Test plan
On a Linux box against this main (this branch's code):
packages/core, each file on its own, 3 runs in a row, all pass every run:restoreAttributes.test.ts(5),editingAgent.test.ts(149),editingPort.test.ts(11),editingGeometry.test.ts(4),editingHandles.test.ts(12),color-grading.test.ts(17).bun run typecheckexits 0.packages/studio, same way:gsapUndoRestore.sealed.test.ts(3),gsapUndoRestore.test.ts(44),CaptionOverlay.sealed.test.ts(5),LayersPanel.opaque.test.ts(3),previewDrafts.test.ts(13),previewGestureStartRead.test.ts(6),previewLayers.test.ts(7),previewOverlayRects.test.ts(9),previewPointerTargets.test.ts(16),previewSelection.test.ts(28),useColorGradingController.sealed.test.ts(4).bun run typecheckexits 0.oxfmt check, oxlint (0 warnings, 0 errors) and
fallow audit --base origin/main(no issues) on the changed files.fails without the fix: with only the test changes applied to main, "changes no handler, URL or sandbox-style attribute, and leaves an unchanged one alone" in
packages/core/src/runtime/editing/restoreAttributes.test.tsand "never hands off in a document Studio's preview server did not mark" inpackages/core/src/runtime/editingAgent.test.tsfail; every other test in the files below passes on main and on this branch.Unit tests added/updated
Manual testing performed
Documentation updated (if applicable)
Comments follow CONTRIBUTING.md "Comments": they say why, not what, and a bug fix says what the code must do and how to reproduce the bug
What I did NOT exercise
injectStudioPreviewAugmentations), and Desktop serves its previews through the same route.src, for one, reloads again.<meta name="hyperframes-studio-preview">and is served by some other server would still offer the port. That needs the project's author, who already runs script in that page.