Skip to content

fix(core): escape author-controlled values in bundler attribute selectors#1568

Open
calcarazgre646 wants to merge 1 commit into
heygen-com:mainfrom
calcarazgre646:fix/bundler-escape-script-src-selector
Open

fix(core): escape author-controlled values in bundler attribute selectors#1568
calcarazgre646 wants to merge 1 commit into
heygen-com:mainfrom
calcarazgre646:fix/bundler-escape-script-src-selector

Conversation

@calcarazgre646

Copy link
Copy Markdown
Contributor

Problem

bundleToSingleHtml interpolated raw attribute values into querySelector attribute selectors at three sites: the external-script dedup (htmlBundler.ts:627, :828) and the sub-composition root lookup (:860). A value containing a " (a quoted query param in a <script src>, or a data-composition-id) produced a malformed selector that throws Attribute selector didn't terminate in css-select, aborting the whole bundle. Since render, validate, snapshot, and layout all call bundleToSingleHtml, one such sub-composition crashes every one of them with an opaque error.

The sibling link[href] dedup (:927) already escapes via .replace(/\\/g, "\\\\").replace(/"/g, '\\"'), and the cssAttributeSelector helper (:279) does exactly that and is already used for data-composition-id at :799 and :863. The three crashing sites just did not use it.

Change

Route all three through cssAttributeSelector. No behavior change for values without " or \ (the escape is a no-op there).

Tests

A bundler test for a sub-composition whose external <script src> contains a ": it now bundles instead of throwing. Verified load-bearing (reverting the fix reproduces Attribute selector didn't terminate). Full core suite green (1912 tests).

…tors

bundleToSingleHtml interpolated raw attribute values into querySelector
attribute selectors at three sites: the external-script dedup
(htmlBundler.ts:627, :828) and the sub-composition root lookup (:860). A
value with a double quote (a quoted query param in a <script src>, or a
data-composition-id) built a malformed selector that throws 'Attribute
selector didn't terminate' in css-select and aborted the whole bundle.
render/validate/snapshot/layout all call bundleToSingleHtml, so one such
sub-composition crashed every one of them.

Route the three sites through the existing cssAttributeSelector helper,
which escapes backslash and quote - the same escaping the sibling
link[href] dedup already applies and the helper is already used for
data-composition-id at :799 and :863.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant