Skip to content

🐛 Normalize Windows symlink path separators#2861

Merged
ChanTsune merged 1 commit into
mainfrom
pna/normalize-symlink-path
May 10, 2026
Merged

🐛 Normalize Windows symlink path separators#2861
ChanTsune merged 1 commit into
mainfrom
pna/normalize-symlink-path

Conversation

@ChanTsune
Copy link
Copy Markdown
Owner

@ChanTsune ChanTsune commented Mar 28, 2026

Windows CreateSymbolicLinkW requires native backslash separators. Normalize forward slashes in symlink targets and link paths before calling symlink_dir/symlink_file to prevent invalid symlink creation.

Summary by CodeRabbit

  • Bug Fixes

    • Windows symlink creation now normalizes forward-slash separators to backslashes, correctly resolves relative targets, and selects the correct symlink type, improving compatibility across varied path formats and edge cases.
    • Preserves non-UTF-8 and Unicode path contents, and handles empty, root, extended-length, and lone-surrogate inputs.
  • Tests

    • Added Windows-focused tests covering separator normalization, relative-target resolution, and Unicode/edge-case path behavior.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 28, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b459b4b8-7666-4a49-95b7-774f7f8cde95

📥 Commits

Reviewing files that changed from the base of the PR and between 3f6c01a and 2520778.

📒 Files selected for processing (1)
  • pna/src/fs.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • pna/src/fs.rs

📝 Walkthrough

Walkthrough

On Windows, symlink now normalizes forward slashes to backslashes for both target and link, resolves relative targets against the link's parent to determine directory-ness, and calls Windows symlink APIs using the normalized paths; Windows-only unit tests were added.

Changes

Windows Symlink Path Normalization & Resolution

Layer / File(s) Summary
Separator normalization helper
pna/src/fs.rs
Add Windows-only normalize_windows_separators that rewrites /\ using UTF-16 operations and returns a borrowed input when unchanged.
Symlink resolution and creation
pna/src/fs.rs
Normalize original and link, resolve is_dir by joining normalized original against the link's parent for relative targets, and call os::windows::fs::symlink_dir / symlink_file with normalized paths.
Tests
pna/src/fs.rs (windows_tests)
Add Windows unit tests for borrowing behavior, mixed inputs, empty and / paths, extended-length \\?\\ paths, lone surrogate preservation, and Unicode preservation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

lib

Poem

🐇 I hop through paths both short and long,

Swapping slashes where they don't belong.
Backslashes march in tidy rows,
Links now find where each one goes.
A little hop — the symlink grows!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: normalizing Windows symlink path separators, which directly addresses the bug fix implemented in the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pna/normalize-symlink-path

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces path normalization for Windows symlinks, ensuring forward slashes are converted to backslashes. The review feedback identifies an opportunity to optimize the normalize_windows_separators function by modifying the wide character vector in-place, thereby reducing unnecessary memory allocations.

Comment thread pna/src/fs.rs Outdated
@ChanTsune ChanTsune force-pushed the pna/normalize-symlink-path branch from 4a6cb75 to 4b64354 Compare March 29, 2026 08:32
@ChanTsune ChanTsune force-pushed the pna/normalize-symlink-path branch from 98a5e44 to 3f6c01a Compare May 9, 2026 13:50
Windows CreateSymbolicLinkW requires native backslash separators.
Normalize forward slashes in symlink targets and link paths before
calling symlink_dir/symlink_file to prevent invalid symlink creation.
@ChanTsune ChanTsune force-pushed the pna/normalize-symlink-path branch from 3f6c01a to 2520778 Compare May 9, 2026 23:33
@ChanTsune ChanTsune merged commit 9666dd8 into main May 10, 2026
110 checks passed
@ChanTsune ChanTsune deleted the pna/normalize-symlink-path branch May 10, 2026 01:37
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