Repository navigation
fix(parsers): allow asset names beginning with two dots - #3759
javierivanov wants to merge 2 commits into
Conversation
2460238 to
0ee4803
Compare
miguel-heygen
left a comment
There was a problem hiding this comment.
Thanks for this. The parsers change is right: a name that starts with two dots is not a parent-directory segment. One change before we can take it: packages/producer/src/utils/paths.ts:62 still treats any path starting with .. as outside the project, so lint would accept an asset like ..intro.mp4 while render still rejects it. Please make the producer use the same segment check (ideally by importing the parsers helper rather than a second copy), add one producer test with a ..name file, and mark the PR ready for review.
|
One correction to my note above: #5834 fixes that same producer check in |
What
Fix local asset resolution and containment checks for valid names beginning with two dots, such as
..intro.mp4and..assets/clip.mp4.Why
The checks treated every relative path starting with
..as traversal. As a result, local assets with these names were rejected even when they were inside the project. The candidate resolver returned no candidates, which can produce false missing-asset reports.How
Check for the complete parent-directory segment (
..or..followed by the platform separator). Apply the same distinction to the existing POSIX-normalized root-clamping fallback. Actual parent and sibling paths remain outside the containment boundary.Test plan
bun run --cwd packages/parsers test --configLoader runner src/assetPaths.test.ts src/assetResolution.test.ts src/rewriteSubCompPaths.test.ts.bun run --cwd packages/parsers typecheck.bun run build.ffBinaries.test.tsWindows failures, reproduced against the original code (Windows exe preference and PATH fallback spy count).Maintainer follow-up
isWithinProjectRootnow takes an injectablepathModule, so the segment check usespathModule.sep(sepadded toPathModuleLike); win32 two-dot names are covered next to the existing win32 traversal tests.reanchoredCandidates(used byresolveProjectRelativeSrc) had the samestartsWith("..")false rejection:../..top.mp4never re-anchored to the root file..top.mp4. Fixed with a regression test.../from a normalized path, the only remaining traversal is a bare.., so both clamp sites check=== ".."...,../x,..\x,..\..\x,%2e%2e/x,%2e%2e%2fx,..%2fx,..%5cx,a/../../x,../proj-sibling/xproduce no candidate outside the project root, and win32..,..\x,D:\x, UNC paths are rejected.Size
Small on purpose: one boundary rule (a
..path segment vs. a name that starts with two dots) applied at the three places that test it, plus focused tests.