fix(core,studio): escape user values in querySelector attribute selectors#1586
Open
miguel-heygen wants to merge 1 commit into
Open
fix(core,studio): escape user values in querySelector attribute selectors#1586miguel-heygen wants to merge 1 commit into
miguel-heygen wants to merge 1 commit into
Conversation
bb69548 to
ccfcafa
Compare
…tors Extract cssAttrSelector to packages/core/src/utils/cssSelector.ts and use it (or CSS.escape for browser-side code) at all 12 sites that previously interpolated raw user-authored values into querySelector attribute selectors. A " in a composition ID, script src, or data-start value would produce a malformed selector that throws. Node-side (core compiler/parser): uses the shared cssAttrSelector. Browser-side (runtime, studio): uses native CSS.escape(). Supersedes #1568 which fixed only the 3 bundler sites.
ccfcafa to
22ff0dd
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.
Summary
queryByAttr(root, attr, value, tag?)topackages/core/src/utils/cssSelector.ts— queries DOM by attribute presence then compares with exact===, zero injection surfacequerySelectorattribute selectorsqueryByAttr— no selector string interpolation at allCSS.escape()A
"in a composition ID, script src URL, ordata-startelement reference would produce a malformed CSS selector that throwsAttribute selector didn't terminatein css-select, crashing the entire pipeline.Supersedes #1568 which fixed only the 3 bundler sites.
Approach
Instead of escaping values and interpolating into selector strings,
queryByAttrqueries for attribute presence ([attr]) then compares with===. The user value never touches a CSS selector — there is nothing to escape and nothing to inject.Fixed sites
htmlBundler.ts:627,828src/extSrc(script src)htmlBundler.ts:860compId(composition ID)inlineSubCompositions.ts:228compIdhtmlParser.ts:522elementId(public API param)picker.ts:100-102compositionId,compositionSrctimelineIframeHelpers.ts:298,306startAttr(user-authored)timelineIframeHelpers.ts:403existing.id(DOM id)timelineElementHelpers.ts:286-287id(clip id + raw class selector)timelineDOM.ts:126clip.compositionIddomEditingElement.ts:245selection.hfIdLayersPanel.tsx:129layer.hfIdTest plan