Repository navigation
fix(producer): render reads a composition src like the preview, refuses paths outside - #7317
Conversation
There was a problem hiding this comment.
Verdict: REQUEST CHANGES · 1 blocker · 1 important · 0 nits · head 6e1404cb
- blocker:
Preflight (lint + format)fails (oxfmt --check:htmlCompiler.test.ts). Because of that,regression-shardswas skipped andregressionis red, so this compile-path change has not been through the render regression suite. ↓ inline - important: the encoded-directory case is only half supported. ↓ inline
Scope
Read all 3 files. Checked every data-composition-src resolution in producer: the three sites changed here, plus recompileWithResolutions, which runs after the pre-flight. Refusing paths outside the project matches the preview bundler (resolveEntryPath → isSafeProjectPath). The tests named on the 'fails without the fix:' line fail at main as claimed: dot-dot used to read the outside file, and a leading slash resolved to the filesystem root. Studio-server resolution was not audited, as the PR says. Windows render verification also fails on main at 410a516c.
| ["an encoded ../", "%2e%2e%2foutside-scene.html"], | ||
| ["a leading slash and dot-dot", "/../outside-scene.html"], | ||
| ["an encoded leading slash and dot-dot", "%2f%2e%2e%2foutside-scene.html"], | ||
| ])("compileForRender refuses a data-composition-src that leaves the project through %s", async (_label, src) => { |
There was a problem hiding this comment.
blocker (CI): oxfmt --check flags this file, most likely this over-long it.each(...)(...) line. Preflight fails, so regression-shards is skipped and regression fails with "Regression shards did not succeed." Run bun run format and push, so the render regression suite actually runs on a producer change.
| } | ||
|
|
||
| /** The project file a data-composition-src names, as the preview reads it; null when it leaves the project. */ | ||
| export function resolveCompositionSrc(projectDir: string, src: string): string | null { |
There was a problem hiding this comment.
important: this decodes the src to find the file, but the inliner and the gsap rewrite still pass the raw srcPath to rewriteAssetPath (parsers/src/rewriteSubCompPaths.ts:79-86). There, compDir keeps %20, so assetExists("my%20dir/img.png") is false. As a result, data-composition-src="my%20dir/scene.html" now renders, but its sibling <img src="img.png"> is not re-pointed and loads from the project root (missing). The new tests only encode the file name. Pass the decoded project-relative path as compSrcPath, or add a case with the encoding in the directory part.
|
Head 9469790: oxfmt applied (Preflight/Format blocker); the encoded-folder finding is fixed at the root: every data-composition-src is rewritten once to its decoded project-relative path (entry html and each sub-composition file read), so rewriteAssetPath and the gsap rewrite see the real folder. New test: an encoded folder with a sibling image fails with the previous head's htmlCompiler.ts and passes now; compiler and paths tests 202 pass, 0 fail. |
There was a problem hiding this comment.
Verdict: APPROVE — 2 resolved, 0 open, 0 new · 6e1404cb → 9469790c
Formatting passes, and the regression shards ran and passed on this head (run 42228938094, shards 1–10). The data-composition-src values are normalized in both the entry and the sub-composition HTML. The subCompositions keys and the inliner's lookups therefore agree, and rewriteAssetPath now gets the decoded folder; the new encoded-folder test covers this. Windows render verification was still running; it also fails on main.
…view to heygen-com#7250 Adopts heygen-com#7310 (MPEG-4 Part 2 / MJPEG get browser-playable copies), heygen-com#7316 (check_report counts the copies a check waited for) and heygen-com#7317 (render reads a composition src like the preview and refuses paths outside the project). Defers heygen-com#7309 (needs heygen-com#6912); heygen-com#7314 does not apply. PR axis advances to heygen-com#7250 (heygen-com#7243 closed unmerged, heygen-com#7249 open and pinned as monitored; monitored 96->97). Co-authored-by: Miguel Ángel <miguel.sierra@heygen.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What changed
The render's compile step now resolves a
data-composition-srcthrough one helper,resolveCompositionSrc(utils/paths.ts), at its three sites inhtmlCompiler.ts(the pre-flight check, the sub-composition reader and the inliner's reader). It decodes%xx, treats a leading/as the project root (the stylesheet reader already does both), keeps a name that exists only as written, and returnsnullwhen the decoded path is not inside the project. Eachdata-composition-srcis also rewritten once, in the entry html and in every sub-composition file the compiler reads, to the decoded project-relative path, so the asset rewriting (rewriteAssetPath) sees the real folder and an encoded folder's sibling images are re-pointed. Anullis reported by the pre-flight as "it is outside the project folder" and read as missing elsewhere.Why
A
compositions/my%20scene.htmlor/compositions/scene.htmlsource is read by the Studio preview but rendered as "the file does not exist" (composition file referenced by data-composition-src cannot be rendered). Reproduced on GitHub runners for 0.9.16 and 0.9.19: plain,./and (on Windows) backslash and wrong-case spellings render; the encoded name and the leading slash fail on both Windows and Linux with that text.The guard matters because decoding opens a way out: before this change
resolve(projectDir, src)already followed../and an absolute path anywhere on the disk, and%2e%2e%2fwould have followed once decoded. A decoded path that leaves the project is now refused.What I measured
htmlCompiler.tsandpaths.tsat main: 6 fail, 2 pass; with the change that file andutils/paths.test.tsgive 202 pass, 0 fail (bun test, Linux box). Also "compileForRender re-points a sibling asset of a sub-composition whose folder is %20-encoded": fails (1 fail) with the previous head'shtmlCompiler.ts, passes with this one.What I did NOT exercise
isPathInsidebut have no test of their own.Size
About 60 changed lines in 3 files, 40 of them tests: a lone fix on one resolver; nothing open on it to carry it.