fix(ext/node): normalize recursive fs mkdir dot-segment paths#35463
fix(ext/node): normalize recursive fs mkdir dot-segment paths#35463nathanwhitbot wants to merge 8 commits into
Conversation
|
Pushed |
|
Pushed a CI follow-up: replaced the direct |
|
Pushed a formatter-only follow-up for the recursive mkdir path normalization helper. The failing lint job was dprint asking for the long return expression in |
|
are you sure this shouldn't be fixed in the rust part of the impl instead of a js normalization? this affect Deno.mkdir as well... |
|
Good catch. I moved the recursive mkdir path normalization into the Rust |
|
Pushed |
|
Nice, small targeted fix. A few notes: Drop the Scope note for the description: because the fix lives in Add a one-line comment on Otherwise LGTM. Good call preserving |
…tion Revert the ext/node/polyfills/fs.ts reflow hunks (no functional change; path preservation comes from not normalizing on the JS side). Add a comment on normalize_recursive_mkdir_path explaining it works around DirBuilder::create failing on trailing dot-segments (denoland#35450).
|
Thanks! Addressed all three:
|
Summary
mkdirso lexical dot-segments like a trailing/.do not make recursive creation fail (matchesmkdir -p). The fix lives inRealFs::mkdir.node:fsmkdir paths containing literal dot segments, plusDeno.mkdirunit coverage.Closes #35450
Scope
Because the fix lives in
RealFs::mkdir, it changes behavior for bothnode:fsmkdir/mkdirSyncandDeno.mkdir/Deno.mkdirSync— e.g.Deno.mkdir("foo/.", { recursive: true })now succeeds instead of failing. This is intentional (covered bytests/unit/mkdir_test.ts) and is a reasonable correctness improvement matchingmkdir -p, though it is broader than theext/nodetitle suggests...segments are deliberately preserved:Path::components()strips.but keepsParentDir, soa/../b/c/.→a/../b/cand the filesystem resolves..itself, avoiding lexical symlink-flattening issues. Pinned by the "preserves parent segment" test.Tests
env -u RUSTC_WRAPPER cargo test -p unit_node_tests --test unit_node -- _fs::_fs_mkdir_test./target/debug/deno fmt --check tests/unit_node/_fs/_fs_mkdir_test.tsgit diff --checkRegression coverage was also checked by temporarily reverting the implementation, rebuilding
deno, and confirming the new dot-segment tests fail withENOENTbefore restoring the fix.